-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1700.py
45 lines (36 loc) · 866 Bytes
/
1700.py
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
45
import sys
from collections import deque
N,K=map(int,sys.stdin.readline().split())
candidate=deque(map(int,sys.stdin.readline().split()))
multitab=[0]*N
cnt=0
while len(candidate)!=0:
new=candidate.popleft()
if new in multitab:
continue
flag=0
for i in range(N):
if multitab[i]==0:
multitab[i]=new
flag+=1
break
if flag==1:
continue
for i in range(N):
if not multitab[i] in candidate:
multitab[i]=new
cnt+=1
flag+=1
break
if flag==1:
continue
index=0
max=-1
for i in range(N):
num=candidate.index(multitab[i])
if max<num:
max=num
index=i
multitab[index]=new
cnt+=1
print(cnt)