Skip to content

Commit 8e5891f

Browse files
committed
[BOJ]#11053.가장 긴 증가하는 부분 수열/ 실버2/ 3hour
https://www.acmicpc.net/problem/11053
1 parent 406e172 commit 8e5891f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
백준 #11053. 가장 긴 증가하는 부분 수열
3+
https://www.acmicpc.net/problem/11053
4+
5+
# Intutition : DP
6+
7+
가장 긴 증가하는 부분수열
8+
=> 부분수열 내 최대값보다 크면, 부분수열에 추가 & 기준 최대 값 업데이트
9+
10+
# set 은 삽입시 순서를 보장하지 않음(순서 없는 자료형 , 즉 출력 및 삽입시 랜덤하게 섞임)
11+
https://okky.kr/questions/571601
12+
"""
13+
import sys
14+
15+
N = int(sys.stdin.readline())
16+
input_list = list(map(int, sys.stdin.readline().split()))
17+
# dp[i] : 0~ i번째 Subset 중 가장 긴 증가하는 부분 수열 갯수
18+
#
19+
# Subset 중 가장 큰 수 찾기(비교군)
20+
# 비교군 VS 현재값 -> 크면 dp +1 , 작으면 dp
21+
22+
# 0. dp 초기값 : Subset 총 개수
23+
dp = [ 1 for _ in range(N)]
24+
for i in range(1, N) :
25+
for j in range(i):
26+
if input_list[i] > input_list[j] :
27+
dp[i] = max(dp[i] , dp[j]+1)
28+
29+
30+
31+
print(max(dp))

0 commit comments

Comments
 (0)