結果

問題 No.2372 既視感
ユーザー ryohei22
提出日時 2023-07-07 21:41:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 978 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,496 KB
最終ジャッジ日時 2024-07-21 17:28:32
合計ジャッジ時間 3,142 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


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()
        memory[s] += 1
        mcnt += 1
        hist.append(s)
        if N < len(memory):
            memory[hist[i_hist]] -= 1
            mcnt -= 1
            i_hist += 1
    else:
        time = 0
        cnt = 0
        tmp = []
        for _ in range(6):
            t, d = input().split()
            d = int(d)
            if t in memory and 0 < memory[t]:
                time += min(K, d)
            else:
                time += d
            if time <= 60:
                cnt += 1
                tmp.append(t)
        for t in tmp:
            memory[t] += 1
            mcnt += 1
            hist.append(t)
            if N < len(memory):
                memory[hist[i_hist]] -= 1
                mcnt -= 1
                i_hist += 1
        print(cnt)
0