結果

問題 No.2804 Fixer And Ratism
ユーザー hato336
提出日時 2024-07-12 21:11:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 94,248 KB
最終ジャッジ日時 2024-07-12 21:11:46
合計ジャッジ時間 12,134 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#input = sys.stdin.readline
#n = int(input())
#
#alist = []
input = sys.stdin.readline
n,q = map(int,input().split())
h = []
c = collections.defaultdict(int)
for i in range(q):
    t = input().split()
    if t[0] == '1':
        t,s,r = t
        r = int(r)
        heapq.heappush(h,(r,s))
        c[s] = r

    if t[0] == '2':
        t,x = t
        x = int(x)
        n -= x
    if t[0] == '3':
        t,s,x = t
        x = int(x)
        n += x
        h.remove((c[s],s))
        h.append((c[s] | 1<<40,s))
        c[s] |= 1<<40
        heapq.heapify(h)
    while len(h) > n:
        ans = heapq.heappop(h)
        print(ans[1])
0