結果

問題 No.2372 既視感
ユーザー lloyzlloyz
提出日時 2023-07-07 23:02:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 1,117 bytes
コンパイル時間 2,566 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 78,616 KB
最終ジャッジ日時 2023-09-29 00:40:03
合計ジャッジ時間 5,274 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,632 KB
testcase_01 AC 98 ms
71,808 KB
testcase_02 AC 94 ms
71,544 KB
testcase_03 AC 95 ms
71,752 KB
testcase_04 AC 95 ms
71,528 KB
testcase_05 AC 94 ms
71,744 KB
testcase_06 AC 94 ms
71,736 KB
testcase_07 AC 94 ms
71,632 KB
testcase_08 AC 134 ms
77,920 KB
testcase_09 AC 112 ms
76,132 KB
testcase_10 AC 130 ms
77,616 KB
testcase_11 AC 139 ms
77,608 KB
testcase_12 AC 99 ms
71,284 KB
testcase_13 AC 138 ms
77,892 KB
testcase_14 AC 104 ms
72,248 KB
testcase_15 AC 121 ms
76,928 KB
testcase_16 AC 116 ms
76,512 KB
testcase_17 AC 103 ms
72,072 KB
testcase_18 AC 103 ms
72,072 KB
testcase_19 AC 99 ms
71,576 KB
testcase_20 AC 99 ms
71,584 KB
testcase_21 AC 97 ms
71,560 KB
testcase_22 AC 102 ms
71,900 KB
testcase_23 AC 144 ms
77,844 KB
testcase_24 AC 128 ms
77,436 KB
testcase_25 AC 141 ms
77,624 KB
testcase_26 AC 140 ms
77,912 KB
testcase_27 AC 147 ms
77,892 KB
testcase_28 AC 150 ms
78,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque, defaultdict

n, k, q = map(int, input().split())
seen_que = deque()
seen_set = set()
seen_dict = defaultdict(int)
for _ in range(q):
    qq = int(input())
    if qq == 1:
        s = input()
        if len(seen_que) == n:
            rs = seen_que.popleft()
            seen_dict[rs] -= 1
            if seen_dict[rs] == 0:
                seen_set.remove(rs)
        seen_que.append(s)
        seen_dict[s] += 1
        seen_set.add(s)
    elif qq == 2:
        res = 0
        tt = 0
        L = []
        for __ in range(6):
            s, t = input().split()
            t = int(t)
            if s in seen_set:
                tt += min(t, k)
            else:
                tt += t
            if tt <= 60:
                res += 1
                L.append(s)
        for s in L:
            if len(seen_que) == n:
                rs = seen_que.popleft()
                seen_dict[rs] -= 1
                if seen_dict[rs] == 0:
                    seen_set.remove(rs)
            seen_que.append(s)
            seen_dict[s] += 1
            seen_set.add(s)
        print(res)
0