結果

問題 No.2372 既視感
ユーザー flygon
提出日時 2023-07-07 21:37:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 70,144 KB
最終ジャッジ日時 2024-07-21 17:21:47
合計ジャッジ時間 2,855 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n,k,q = map(int,input().split())

a = deque()
d = defaultdict(int)

for i in range(q):
    t = int(input())
    if t == 1:
        s = input().rstrip()
        a.append(s)
        d[s] += 1
        while len(a) > n:
            d[a.popleft()] -= 1
    else:
        now = 0
        cnt = 0
        sol = []
        for i in range(6):
            l = list(input().split())
            t = int(l[1])
            if d[l[0]] >= 1:
                t = min(t, k)
            if now + t <= 60:
                cnt += 1
                sol.append(l[0])
            now += t
        for pro in sol:
            a.append(pro)
            d[pro] += 1
        while len(a) > n:
            d[a.popleft()] -= 1
        print(cnt)

0