diff --git a/workbook_7319/silver/11055-s2.py b/workbook_7319/silver/11055-s2.py new file mode 100644 index 0000000..13153af --- /dev/null +++ b/workbook_7319/silver/11055-s2.py @@ -0,0 +1,29 @@ +# 가장 큰 증가하는 부분 수열 + +import sys + +input = sys.stdin.readline + +def solution(): + n = int(input().rstrip()) + + lst = list(map(int, input().rstrip().split())) + dp = lst[:] + + for i in range(1, n): + dp[i] = max([dp[j]+lst[i] for j in range(i-1, -1, -1) if lst[j] < lst[i]] + [lst[i]]) + + print(max(dp)) + + return + + +solution() + +""" +걸린 시간: 25분 + +시간 복잡도: 하나의 값을 볼때 내 앞에 있는 값들을 다 확인해봐야하기 때문에 O(n^2)이다. + +해설: 현재 보는 값보다 앞에 나온 작은 놈들의 dp 값에 나를 더하면, 이는 앞에 나온 수열 중 내가 붙을 수 있는 것들 중에 값이 최대인 것에 붙겠다라는 뜻이다. +""" \ No newline at end of file