Skip to content

Commit 6191e69

Browse files
authored
Merge pull request #67 from YoonYn9915/main
YoonYn9915 / 10월 1주차 / 2문제
2 parents feb52ea + 4c8f16a commit 6191e69

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
n = int(input())
2+
3+
dp = [1, 1, 2, 3, 5, 8]
4+
5+
if n > 5:
6+
for i in range(6, n):
7+
dp.append(dp[i-1] + dp[i-2])
8+
9+
ans = (dp[n-1] * 2) + ((dp[n-1] + dp[n-2]) * 2)
10+
11+
if n == 1:
12+
ans = 4
13+
14+
print(ans)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
def sort(arr,dp):
3+
global N
4+
5+
for i in range(1,N,1):
6+
for j in range(i-1,-1,-1):
7+
if arr[j] > arr[i]:
8+
dp[i] = max(dp[i],dp[j]+1)
9+
10+
11+
N = int(input())
12+
13+
arr = list(map(int,input().split()))
14+
dp = [1] * N
15+
16+
sort(arr, dp)
17+
18+
print(N-max(dp))
19+

0 commit comments

Comments
 (0)