BOJ - 12015 - 가장 긴 증가하는 부분 수열 2
Updated:
import sys
def solution():
N = int(input())
number = list(map(int, sys.stdin.readline().split()))
dp = [0]
for num in number:
if dp[-1] < num:
dp.append(num)
else:
low = 0
high = len(dp) - 1
while low < high:
mid = (low + high) // 2
if dp[mid] < num:
low = mid + 1
elif dp[mid] > num:
high = mid
else:
low = high = mid
dp[high] = num
print(len(dp)-1)
solution()
https://www.acmicpc.net/problem/12015
Leave a comment