結果
問題 | No.1705 Mode of long array |
ユーザー |
|
提出日時 | 2021-10-23 17:39:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 361 ms / 3,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 461 ms |
コンパイル使用メモリ | 81,848 KB |
実行使用メモリ | 103,508 KB |
最終ジャッジ日時 | 2024-09-25 08:50:54 |
合計ジャッジ時間 | 15,394 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
from heapq import heapify, heappop,heappush N,M = map(int,input().split()) A = list(map(int,input().split())) hq = [] for i,a in enumerate(A): heappush(hq,(-a,-i-1)) num = [0]+A[:] q = int(input()) Q = [tuple(map(int,input().split()))for _ in range(q)] for t,x,y in Q: if t==1: num[x]+=y heappush(hq,(-num[x],-x)) elif t==2: num[x]-=y heappush(hq,(-num[x],-x)) else: while num[-hq[0][1]]!=-hq[0][0]: heappop(hq) print(-hq[0][1])