-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_1713.py
More file actions
30 lines (27 loc) · 836 Bytes
/
Copy pathbj_1713.py
File metadata and controls
30 lines (27 loc) · 836 Bytes
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
import sys
sys.stdin = open('bj_1713_in.txt', 'r')
input = sys.stdin.readline
n = int(input().strip())
# print(n)
cnt = int(input().strip())
# print(student)
recommend = list(map(int, input().strip().split()))
# print(recommend)
frame = []
candidates_info = dict()
# print(len(dq))
for idx, person in enumerate(recommend):
if person in frame: #존재하면
candidates_info[person][0] += 1 #업데이트
else: #존재하지 않으면
if len(frame) >= n: #후보에서 방출
out = min(frame, key=lambda x: candidates_info[x])
frame.remove(out)
candidates_info.pop(out)
# 후보에 추가
frame.append(person)
candidates_info[person] = [1, idx] # 추천횟수, 추천등록시기
# print(frame)
frame.sort()
print(*frame)
# print(candidates_info)