結果
問題 | No.1705 Mode of long array |
ユーザー |
![]() |
提出日時 | 2021-10-08 23:03:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 489 ms / 3,000 ms |
コード長 | 784 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 82,340 KB |
実行使用メモリ | 112,188 KB |
最終ジャッジ日時 | 2024-07-23 06:26:03 |
合計ジャッジ時間 | 20,361 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
from collections import defaultdictfrom heapq import heappush, heappopHC = defaultdict(int)H = []def hpush(x):heappush(H, -x)HC[x] += 1def hpop():t = -heappop(H)while not HC[t]:t = -heappop(H)HC[t] -= 1return tdef hmax():a = hpop()hpush(a)return adef hdel(x):assert HC[x] > 0HC[x] -= 1N, M = map(int, input().split())A = [int(a) for a in input().split()]for i, a in enumerate(A):hpush(a * M + i)Q = int(input())for _ in range(Q):t, x, y = map(int, input().split())x -= 1if t == 1:hdel(A[x] * M + x)A[x] += yhpush(A[x] * M + x)elif t == 2:hdel(A[x] * M + x)A[x] -= yhpush(A[x] * M + x)else:print(hmax() % M + 1)