結果
問題 | No.1705 Mode of long array |
ユーザー |
![]() |
提出日時 | 2021-10-08 23:11:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 423 ms / 3,000 ms |
コード長 | 611 bytes |
コンパイル時間 | 346 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 103,424 KB |
最終ジャッジ日時 | 2024-07-23 06:48:33 |
合計ジャッジ時間 | 18,143 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
from collections import Counterimport heapqN,M=map(int,input().split())A=list(map(int,input().split()))Q=int(input())H=[]C=Counter()for i in range(M):a=A[i]C[i+1]=aH.append((-a,-(i+1)))heapq.heapify(H)#print(H)for queries in range(Q):t,x,y=map(int,input().split())if t==1:C[x]+=yheapq.heappush(H,(-C[x],-x))elif t==2:C[x]-=yheapq.heappush(H,(-C[x],-x))else:while True:z,w=H[0]if C[-w]!=-z:heapq.heappop(H)else:breakprint(-H[0][1])