結果

問題 No.1705 Mode of long array
ユーザー Kiri8128Kiri8128
提出日時 2021-10-08 23:03:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 547 ms / 3,000 ms
コード長 784 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 118,212 KB
最終ジャッジ日時 2023-09-30 12:23:38
合計ジャッジ時間 23,403 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,680 KB
testcase_01 AC 95 ms
71,752 KB
testcase_02 AC 95 ms
71,684 KB
testcase_03 AC 173 ms
78,752 KB
testcase_04 AC 150 ms
77,952 KB
testcase_05 AC 181 ms
78,748 KB
testcase_06 AC 270 ms
80,584 KB
testcase_07 AC 286 ms
81,484 KB
testcase_08 AC 289 ms
81,420 KB
testcase_09 AC 276 ms
80,212 KB
testcase_10 AC 264 ms
81,388 KB
testcase_11 AC 283 ms
82,088 KB
testcase_12 AC 269 ms
80,828 KB
testcase_13 AC 488 ms
103,004 KB
testcase_14 AC 437 ms
96,424 KB
testcase_15 AC 451 ms
92,096 KB
testcase_16 AC 493 ms
95,700 KB
testcase_17 AC 438 ms
90,364 KB
testcase_18 AC 415 ms
91,136 KB
testcase_19 AC 512 ms
98,780 KB
testcase_20 AC 436 ms
91,784 KB
testcase_21 AC 444 ms
98,924 KB
testcase_22 AC 531 ms
106,528 KB
testcase_23 AC 316 ms
93,344 KB
testcase_24 AC 324 ms
93,832 KB
testcase_25 AC 322 ms
93,152 KB
testcase_26 AC 321 ms
93,492 KB
testcase_27 AC 314 ms
92,968 KB
testcase_28 AC 324 ms
93,820 KB
testcase_29 AC 314 ms
93,228 KB
testcase_30 AC 330 ms
92,832 KB
testcase_31 AC 330 ms
93,244 KB
testcase_32 AC 321 ms
93,384 KB
testcase_33 AC 398 ms
117,472 KB
testcase_34 AC 387 ms
118,212 KB
testcase_35 AC 386 ms
117,068 KB
testcase_36 AC 384 ms
117,984 KB
testcase_37 AC 388 ms
116,996 KB
testcase_38 AC 394 ms
117,932 KB
testcase_39 AC 390 ms
118,016 KB
testcase_40 AC 393 ms
118,036 KB
testcase_41 AC 384 ms
118,092 KB
testcase_42 AC 385 ms
118,200 KB
testcase_43 AC 486 ms
93,884 KB
testcase_44 AC 511 ms
93,900 KB
testcase_45 AC 510 ms
93,956 KB
testcase_46 AC 512 ms
94,012 KB
testcase_47 AC 545 ms
93,740 KB
testcase_48 AC 547 ms
93,992 KB
testcase_49 AC 513 ms
104,812 KB
testcase_50 AC 519 ms
104,628 KB
testcase_51 AC 522 ms
105,308 KB
testcase_52 AC 523 ms
105,748 KB
testcase_53 AC 507 ms
104,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from heapq import heappush, heappop

HC = defaultdict(int)
H = []

def hpush(x):
    heappush(H, -x)
    HC[x] += 1
def hpop():
    t = -heappop(H)
    while not HC[t]:
        t = -heappop(H)
    HC[t] -= 1
    return t
def hmax():
    a = hpop()
    hpush(a)
    return a
def hdel(x):
    assert HC[x] > 0
    HC[x] -= 1

N, 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 -= 1
    if t == 1:
        hdel(A[x] * M + x)
        A[x] += y
        hpush(A[x] * M + x)
    elif t == 2:
        hdel(A[x] * M + x)
        A[x] -= y
        hpush(A[x] * M + x)
    else:
        print(hmax() % M + 1)
0