結果

問題 No.2372 既視感
ユーザー mo124121mo124121
提出日時 2023-07-07 21:33:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 85,660 KB
最終ジャッジ日時 2023-09-28 22:33:00
合計ジャッジ時間 7,274 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
81,152 KB
testcase_01 AC 176 ms
81,208 KB
testcase_02 AC 173 ms
81,136 KB
testcase_03 AC 176 ms
81,196 KB
testcase_04 AC 178 ms
81,228 KB
testcase_05 AC 175 ms
81,212 KB
testcase_06 AC 174 ms
81,144 KB
testcase_07 AC 174 ms
81,204 KB
testcase_08 AC 210 ms
84,824 KB
testcase_09 AC 192 ms
83,800 KB
testcase_10 AC 207 ms
84,856 KB
testcase_11 AC 214 ms
84,728 KB
testcase_12 AC 173 ms
81,028 KB
testcase_13 AC 215 ms
84,880 KB
testcase_14 AC 180 ms
81,160 KB
testcase_15 AC 196 ms
84,396 KB
testcase_16 AC 190 ms
83,892 KB
testcase_17 AC 175 ms
81,156 KB
testcase_18 AC 174 ms
81,076 KB
testcase_19 AC 173 ms
81,168 KB
testcase_20 AC 179 ms
81,084 KB
testcase_21 AC 177 ms
81,208 KB
testcase_22 AC 176 ms
80,992 KB
testcase_23 AC 232 ms
84,884 KB
testcase_24 AC 211 ms
84,728 KB
testcase_25 AC 223 ms
85,028 KB
testcase_26 AC 217 ms
84,892 KB
testcase_27 AC 223 ms
85,048 KB
testcase_28 AC 232 ms
85,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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