← Back to List

17931번: Greedily Increasing Subsequence ↗

Solutions

Python 3
164 B | 164 chars
n = int(input())
L = list(map(int,input().split()))
R = [L[0]]
for i in L[1:]:
    if R[-1] < i:
        R.append(i)
print(len(R))
print(" ".join(list(map(str,R))))