-
Notifications
You must be signed in to change notification settings - Fork 0
/
BOJ_12015.py
57 lines (44 loc) · 1.02 KB
/
BOJ_12015.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# n = int(input())
# l = list(map(int, input().split()))
# dp = [1 for _ in range(n)]
# ans = 0
#
# for i in range(n):
# for j in range(0, i):
# if l[i] > l[j]:
# dp[i] = max(dp[i], dp[j] + 1)
# ans = max(dp[i], ans)
#
# print(ans)
# def lower_bound(length, value):
# for i in range(length):
# if vt[i] == value:
# return
# elif vt[i] > value:
# vt[i] = value
# return
# if vt[0] > value:
# vt[0] = value
# return
# n = int(input())
# l = list(map(int, input().split()))
# vt = [0 for _ in range(n)]
# vt[0] = l[0]
# ans = 0
# for i in range(n):
# if vt[ans] < l[i]:
# ans += 1
# vt[ans] = l[i]
# else:
# lower_bound(ans+1, l[i])
# print(ans+1)
import sys
from bisect import bisect_left
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
stack = [0]
for i in l:
if stack[-1] < i: stack.append(i)
else: stack[bisect_left(stack, i)] = i
print(len(stack)-1)