結果

問題 No.714 回転寿司屋のシミュレート
ユーザー qumazakiqumazaki
提出日時 2020-09-01 00:48:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 904 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-04-28 11:44:21
合計ジャッジ時間 3,342 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 36 ms
52,224 KB
testcase_02 AC 37 ms
52,608 KB
testcase_03 AC 41 ms
53,248 KB
testcase_04 AC 42 ms
53,760 KB
testcase_05 AC 45 ms
54,528 KB
testcase_06 AC 55 ms
64,512 KB
testcase_07 AC 72 ms
71,040 KB
testcase_08 AC 91 ms
76,288 KB
testcase_09 AC 94 ms
76,416 KB
testcase_10 AC 86 ms
73,472 KB
testcase_11 AC 53 ms
62,464 KB
testcase_12 AC 62 ms
66,816 KB
testcase_13 AC 54 ms
63,872 KB
testcase_14 AC 56 ms
64,000 KB
testcase_15 AC 54 ms
64,384 KB
testcase_16 AC 50 ms
62,592 KB
testcase_17 AC 79 ms
73,344 KB
testcase_18 AC 56 ms
63,872 KB
testcase_19 AC 53 ms
62,848 KB
testcase_20 AC 51 ms
63,232 KB
testcase_21 AC 52 ms
63,232 KB
testcase_22 AC 58 ms
65,152 KB
testcase_23 AC 69 ms
67,840 KB
testcase_24 AC 55 ms
64,128 KB
testcase_25 AC 61 ms
65,792 KB
testcase_26 AC 46 ms
54,912 KB
testcase_27 AC 77 ms
71,680 KB
testcase_28 AC 55 ms
62,208 KB
testcase_29 AC 47 ms
60,544 KB
testcase_30 AC 40 ms
52,736 KB
testcase_31 AC 37 ms
52,480 KB
testcase_32 AC 38 ms
52,480 KB
testcase_33 AC 38 ms
52,224 KB
testcase_34 AC 38 ms
52,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)))
0