### 백준 유사 문제 공유합니다

이거 풀어 봤으면 바로 풀 수 있습니다

###### 작성중인 코드―solution.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
46
47
48
49
50
51
import copy
import heapq
def solution(k, room_number):
visited=dict()
stack=[]
for i in room_number:
if i in visited:
visited[i]+=1
else:
visited[i]=1
temp=copy.deepcopy(list(visited.keys()))
temp.sort(reverse=True)
while temp:
if visited[temp[len(temp)-1]]!=1:
if temp[len(temp)-1]+1 not in visited:
visited[temp[len(temp)-1]+1]=visited[temp[len(temp) -1]]-1
cache=temp[len(temp)-1]+1
visited[temp[len(temp) - 1]] = 1
temp.pop()
temp.append(cache)
else:
visited[temp[len(temp)-1]+1]+=visited[temp[len(temp) -1]]-1
visited[temp[len(temp) - 1]] = 1
temp.pop()
else:
temp.pop()
room=list(visited.keys())
room.sort(reverse=True)
people=[]
for i in range(len(room_number)):
people.append((i,room_number[i])) #우선순위, 방번호
people.sort(key=lambda x:(-x[1],-x[0]))
queue=[]
while room:
while True:
if people:
if people[len(people)-1][1]==room[len(room)-1]:
heapq.heappush(queue,people.pop())
else:
break
else:
break