結果
問題 |
No.2804 Fixer And Ratism
|
ユーザー |
|
提出日時 | 2025-03-21 20:39:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,238 ms / 2,000 ms |
コード長 | 949 bytes |
コンパイル時間 | 492 ms |
コンパイル使用メモリ | 81,784 KB |
実行使用メモリ | 97,720 KB |
最終ジャッジ日時 | 2025-03-21 20:39:49 |
合計ジャッジ時間 | 18,577 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
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) a = [] while len(h) > n: ans = heapq.heappop(h) ans = list(ans) if (ans[0] >> 40) & 1 == 1: ans[0] -= 1<<40 a.append((ans[0],ans[1])) a.sort() for k,l in a: print(l)