結果
| 問題 | No.2372 既視感 | 
| コンテスト | |
| ユーザー |  mo124121 | 
| 提出日時 | 2023-07-07 21:33:57 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 127 ms / 2,000 ms | 
| コード長 | 803 bytes | 
| コンパイル時間 | 398 ms | 
| コンパイル使用メモリ | 82,256 KB | 
| 実行使用メモリ | 78,776 KB | 
| 最終ジャッジ日時 | 2024-07-21 17:17:48 | 
| 合計ジャッジ時間 | 3,858 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 | 
ソースコード
from collections import deque
from typing import Counter
N, K, Q = map(int, input().split())
count = Counter()
q = deque()
for _ in range(Q):
    t = int(input())
    if t == 1:
        s = input()
        count[s] += 1
        q.append(s)
    else:
        TD = []
        for _ in range(6):
            t, d = input().split()
            TD.append((t, int(d)))
        ans = 0
        total = 0
        for t, d in TD:
            if t in count:
                d = min(d, K)
            if total + d <= 60:
                ans += 1
                total += d
                count[t] += 1
                q.append(t)
            else:
                break
        print(ans)
    while len(q) > N:
        u = q.popleft()
        count[u] -= 1
        if count[u] == 0:
            del count[u]
            
            
            
        