結果
| 問題 | 
                            No.714 回転寿司屋のシミュレート
                             | 
                    
| コンテスト | |
| ユーザー | 
                             qumazaki
                         | 
                    
| 提出日時 | 2020-09-01 00:48:52 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 89 ms / 2,000 ms | 
| コード長 | 904 bytes | 
| コンパイル時間 | 177 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 76,672 KB | 
| 最終ジャッジ日時 | 2024-11-17 03:01:27 | 
| 合計ジャッジ時間 | 3,380 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 35 | 
ソースコード
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from heapq import heappop,heappush
n = int(readline())
data = readlines()
ans = []
x = 10000
present = set()
seat = [-1] * 21
dh = dict()
for i,s in enumerate(data):
    s = s.split()
    if(s[0] == '0'):
        ni = int(s[1])
        present.add(i)
        seat[ni] = i
        for si in s[3:]:
            if(not si in dh):
                dh[si] = []
            heappush(dh[si], ni*x+i)
    elif(s[0]== '1'):
        bi = s[1]
        if(not bi in dh):
            dh[bi] = []
        while(dh[bi]):
            num = heappop(dh[bi])
            nj = num//x
            j = num%x
            if(j in present):
                ans.append(nj)
                break
        else:
            ans.append(-1)
    else:
        ci = int(s[1])
        present.remove(seat[ci])
print('\n'.join(map(str,ans)))
            
            
            
        
            
qumazaki