結果

問題 No.1705 Mode of long array
ユーザー titiatitia
提出日時 2021-10-08 23:11:39
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 460 ms / 3,000 ms
コード長 611 bytes
コンパイル時間 1,028 ms
コンパイル使用メモリ 86,552 KB
実行使用メモリ 118,708 KB
最終ジャッジ日時 2023-09-30 12:46:31
合計ジャッジ時間 21,566 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,480 KB
testcase_01 AC 97 ms
71,744 KB
testcase_02 AC 89 ms
71,460 KB
testcase_03 AC 132 ms
78,012 KB
testcase_04 AC 137 ms
77,852 KB
testcase_05 AC 150 ms
78,364 KB
testcase_06 AC 201 ms
79,736 KB
testcase_07 AC 206 ms
79,492 KB
testcase_08 AC 202 ms
79,240 KB
testcase_09 AC 205 ms
79,664 KB
testcase_10 AC 193 ms
78,960 KB
testcase_11 AC 198 ms
79,968 KB
testcase_12 AC 183 ms
79,116 KB
testcase_13 AC 382 ms
108,784 KB
testcase_14 AC 328 ms
95,584 KB
testcase_15 AC 334 ms
83,596 KB
testcase_16 AC 365 ms
88,148 KB
testcase_17 AC 319 ms
84,400 KB
testcase_18 AC 298 ms
84,736 KB
testcase_19 AC 373 ms
89,176 KB
testcase_20 AC 312 ms
87,176 KB
testcase_21 AC 349 ms
104,968 KB
testcase_22 AC 401 ms
117,824 KB
testcase_23 AC 313 ms
86,384 KB
testcase_24 AC 304 ms
86,936 KB
testcase_25 AC 298 ms
85,972 KB
testcase_26 AC 297 ms
85,776 KB
testcase_27 AC 300 ms
86,036 KB
testcase_28 AC 254 ms
84,548 KB
testcase_29 AC 252 ms
84,052 KB
testcase_30 AC 291 ms
85,436 KB
testcase_31 AC 300 ms
85,412 KB
testcase_32 AC 251 ms
84,208 KB
testcase_33 AC 361 ms
118,420 KB
testcase_34 AC 363 ms
118,576 KB
testcase_35 AC 360 ms
118,616 KB
testcase_36 AC 359 ms
118,684 KB
testcase_37 AC 360 ms
118,708 KB
testcase_38 AC 358 ms
118,668 KB
testcase_39 AC 362 ms
118,676 KB
testcase_40 AC 361 ms
118,432 KB
testcase_41 AC 361 ms
118,520 KB
testcase_42 AC 362 ms
118,640 KB
testcase_43 AC 403 ms
116,672 KB
testcase_44 AC 434 ms
116,676 KB
testcase_45 AC 435 ms
116,700 KB
testcase_46 AC 416 ms
116,816 KB
testcase_47 AC 431 ms
116,824 KB
testcase_48 AC 437 ms
116,804 KB
testcase_49 AC 437 ms
116,664 KB
testcase_50 AC 441 ms
116,852 KB
testcase_51 AC 445 ms
116,596 KB
testcase_52 AC 460 ms
116,480 KB
testcase_53 AC 452 ms
116,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
import heapq

N,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]=a
    H.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]+=y
        heapq.heappush(H,(-C[x],-x))
    elif t==2:
        C[x]-=y
        heapq.heappush(H,(-C[x],-x))
    else:
        while True:
            z,w=H[0]

            if C[-w]!=-z:
                heapq.heappop(H)
            else:
                break

        print(-H[0][1])
0