結果

問題 No.714 回転寿司屋のシミュレート
ユーザー ntuda
提出日時 2025-01-12 19:18:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 940 bytes
コンパイル時間 2,582 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 78,464 KB
最終ジャッジ日時 2025-01-12 19:18:43
合計ジャッジ時間 8,863 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *
from collections import defaultdict
removed = set()
dic = defaultdict(list)
cnt = 1
C2S = [] #客番→席番
S2C = [-1] * 21 #席番→客番
cstm = 0
for _ in range(int(input())):
    t, *dat = list(input().split())
    t = int(t)
    if t == 0:
        seat, n, *dishes = dat
        seat = int(seat)
        C2S.append(seat)
        S2C[seat] = cstm
        for d in dishes:
            heappush(dic[d],(seat,cstm))
        cstm += 1
    elif t == 1:
        d = dat[0]
        if d in dic:
            while dic[d] and dic[d][0][1] in removed:
                _,_ = heappop(dic[d])
            if dic[d]:
                s,c = heappop(dic[d])
                print(C2S[c])
                cnt += 1
            else:
                print(-1)
                cnt += 1
        else:
            print(-1)
            cnt += 1
    else:
        seat = int(dat[0])
        removed.add(S2C[seat])
        S2C[seat] = -1
0