Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- ain = list(map(int, input().split()))
- d = []
- p = []
- for i in range(len(ain)):
- d.append(1)
- p.append(-1)
- for j in range(i):
- if ain[i] > ain[j]:
- if d[j] >= d[i]:
- d[i] = d[j] + 1
- p[i] = j
- m = max(d)
- print(m)
- c = d.index(m)
- st = deque()
- st.append(c)
- while(c != -1):
- c = p[c]
- st.append(c)
- st.pop()
- while len(st) != 0:
- c = st.pop()
- print(ain[c], = ' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement