結果

問題 No.2372 既視感
ユーザー ryohei22ryohei22
提出日時 2023-07-07 21:52:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 958 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 78,424 KB
最終ジャッジ日時 2023-09-28 23:02:03
合計ジャッジ時間 5,888 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,296 KB
testcase_01 AC 94 ms
71,448 KB
testcase_02 AC 96 ms
71,396 KB
testcase_03 AC 96 ms
71,484 KB
testcase_04 AC 94 ms
71,676 KB
testcase_05 AC 94 ms
71,620 KB
testcase_06 AC 93 ms
71,528 KB
testcase_07 AC 95 ms
71,412 KB
testcase_08 AC 132 ms
77,656 KB
testcase_09 AC 111 ms
75,956 KB
testcase_10 AC 132 ms
77,868 KB
testcase_11 AC 137 ms
77,888 KB
testcase_12 AC 95 ms
71,364 KB
testcase_13 AC 136 ms
77,668 KB
testcase_14 AC 104 ms
71,972 KB
testcase_15 AC 121 ms
76,852 KB
testcase_16 AC 116 ms
75,992 KB
testcase_17 AC 104 ms
72,088 KB
testcase_18 AC 103 ms
72,356 KB
testcase_19 AC 98 ms
71,444 KB
testcase_20 AC 97 ms
71,360 KB
testcase_21 AC 97 ms
71,304 KB
testcase_22 AC 108 ms
72,048 KB
testcase_23 AC 150 ms
77,880 KB
testcase_24 AC 139 ms
77,492 KB
testcase_25 AC 144 ms
77,736 KB
testcase_26 AC 135 ms
77,604 KB
testcase_27 AC 143 ms
77,600 KB
testcase_28 AC 151 ms
78,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


def add_(a):
    global memory, mcnt, hist, i_hist
    memory[a] += 1
    mcnt += 1
    hist.append(a)
    if N < mcnt:
        memory[hist[i_hist]] -= 1
        mcnt -= 1
        i_hist += 1


N, K, Q = map(int, input().split())

memory = defaultdict(int)
mcnt = 0
hist = []
i_hist = 0
for _ in range(Q):
    a = int(input())
    if a == 1:
        s = input()
        add_(s)
    else:
        time = 0
        solve = []
        for _ in range(6):
            t, d = input().split()
            d = int(d)
            if t in memory and 0 < memory[t]:
                time += min(d, K)
            else:
                time += d
            if time <= 60:
                solve.append(t)
        print(len(solve))
        for t in solve:
            add_(t)
0