1. Problem
2. Others' Solutions
import sys
n = int(sys.stdin.readline().rstrip()) # n = 6
seqeunce = [0] +list(map(int,sys.stdin.readline().rstrip().split()))
dp = [1] * (n+1)
result = []
for i in range(1,n+1):
for j in range(1,i):
if seqeunce[j] < seqeunce[i]:
dp[i] = max(dp[i], dp[j] + 1)
temp = max(dp)
for i in range(n,0,-1):
if dp[i] == temp:
result.append(seqeunce[i])
temp -= 1
print(max(dp))
print(' '.join(map(str,sorted(result))))
3. Learned