-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ-34
More file actions
44 lines (44 loc) · 1.02 KB
/
Q-34
File metadata and controls
44 lines (44 loc) · 1.02 KB
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
import copy
n=int(input())
a=[15,11,4,8,5,2,4]
result=0
error=0
def check(a):
global error
error=0
if len(a)==1:
error=n-1
else:
for i in range(len(a)-1):
if a[i]<a[i+1]:
error+=1
return error
def fix(a):
if len(a)==1:
return False
else:
for i in range(len(a)):
if a[i]<a[i+1]:
a.remove(a[i]) #어차피 순서가 안맞는 부분은 *무조건* 둘 중 하나를 지워야하므로 앞에서부터 지워도 상관없음
return a
def fix2(a):
if len(a)==1:
return False
else:
for i in range(len(a)):
if a[i]<a[i+1]:
a.remove(a[i+1])
return a
def solution(a):
global result
if check(a)==0 or len(a)==1:
result=max(result,len(a))
return
dp=copy.deepcopy(a) #***
solution(fix(a)) #***
a=dp #***
solution(fix2(a)) #***
a=dp #***
return
solution(a)
print(n-result)