https://www.acmicpc.net/problem/20006
'''
입장 신청시 매칭불가능하면 새로운 방 생성
-10부터 +10렙까지 입장가능
매칭가능하면 입장시키고 정원이 모두 찰 때까지 대기
가장 먼저 생성된 방 순서로 입장
정원 모두 차면 게임 시작
'''
'''
[출력]
게임시작 유무(Started! Waiting!)
방에 있는 플레이어들의 레벨, 아이디 -> 닉네임 사전순
방 생성된 순서대로 출력
'''
import sys
input = sys.stdin.readline
p, m = map(int,input().split()) # 플레이어 수, 방 한개의 정원
rooms = []
for _ in range(p):
l, n = input().split() # 플레이어 레벨, 플레이어 닉네임
l = int(l)
if not rooms:
rooms.append([(l,n)])
else:
for room in rooms:
if room[0][0]-10 <= l <= room[0][0]+10 and len(room) < m:
room.append((l,n))
break
else:
rooms.append([(l,n)])
for room in rooms:
room.sort(key= lambda x : x[1])
if len(room) == m:
print("Started!")
else:
print("Waiting!")
for r in room:
print(*r)
'백준' 카테고리의 다른 글
백준 16928. 뱀과 사다리 게임 (0) | 2025.02.14 |
---|---|
백준 11501. 주식 (0) | 2025.02.07 |
백준 20055. 컨테이너 벨트 위의 로봇 (0) | 2025.02.03 |
백준 1927. 최소 힙 (0) | 2025.02.03 |
백준 12919. A와 B 2 (0) | 2025.02.02 |