結果

問題 No.1705 Mode of long array
ユーザー ああいいああいい
提出日時 2021-12-28 17:23:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,649 ms / 3,000 ms
コード長 1,056 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 46,656 KB
最終ジャッジ日時 2024-04-10 08:34:30
合計ジャッジ時間 49,259 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 29 ms
11,008 KB
testcase_03 AC 41 ms
11,008 KB
testcase_04 AC 41 ms
11,008 KB
testcase_05 AC 47 ms
11,008 KB
testcase_06 AC 85 ms
11,136 KB
testcase_07 AC 99 ms
11,136 KB
testcase_08 AC 93 ms
11,008 KB
testcase_09 AC 86 ms
10,880 KB
testcase_10 AC 82 ms
10,880 KB
testcase_11 AC 89 ms
11,264 KB
testcase_12 AC 88 ms
11,008 KB
testcase_13 AC 1,120 ms
41,520 KB
testcase_14 AC 791 ms
26,940 KB
testcase_15 AC 840 ms
14,848 KB
testcase_16 AC 949 ms
15,488 KB
testcase_17 AC 696 ms
15,104 KB
testcase_18 AC 555 ms
15,104 KB
testcase_19 AC 1,079 ms
20,624 KB
testcase_20 AC 653 ms
19,088 KB
testcase_21 AC 888 ms
40,208 KB
testcase_22 AC 1,307 ms
42,748 KB
testcase_23 AC 601 ms
11,008 KB
testcase_24 AC 600 ms
10,880 KB
testcase_25 AC 601 ms
10,880 KB
testcase_26 AC 600 ms
10,880 KB
testcase_27 AC 597 ms
11,008 KB
testcase_28 AC 594 ms
10,880 KB
testcase_29 AC 602 ms
10,880 KB
testcase_30 AC 596 ms
10,880 KB
testcase_31 AC 590 ms
10,880 KB
testcase_32 AC 595 ms
10,880 KB
testcase_33 AC 1,649 ms
46,644 KB
testcase_34 AC 1,611 ms
46,580 KB
testcase_35 AC 1,638 ms
46,516 KB
testcase_36 AC 1,602 ms
46,516 KB
testcase_37 AC 1,617 ms
46,656 KB
testcase_38 AC 1,631 ms
46,576 KB
testcase_39 AC 1,612 ms
46,576 KB
testcase_40 AC 1,613 ms
46,576 KB
testcase_41 AC 1,613 ms
46,576 KB
testcase_42 AC 1,615 ms
46,576 KB
testcase_43 AC 969 ms
41,844 KB
testcase_44 AC 975 ms
41,904 KB
testcase_45 AC 977 ms
41,840 KB
testcase_46 AC 960 ms
41,780 KB
testcase_47 AC 986 ms
41,908 KB
testcase_48 AC 991 ms
41,776 KB
testcase_49 AC 1,441 ms
43,120 KB
testcase_50 AC 1,455 ms
43,124 KB
testcase_51 AC 1,427 ms
43,124 KB
testcase_52 AC 1,445 ms
43,192 KB
testcase_53 AC 1,448 ms
43,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
a = list(map(int,input().split()))

n = 1
while n < M:
    n <<= 1
dat = [[0] * 2 for _ in range(2 * n - 1)]
for i in range(M):
    j = i + n - 1
    #dat[j] = [a[i],i + 1]
    dat[j][0] = a[i]
    dat[j][1] = i + 1

def add(i,x):
    j = i - 1 + n - 1
    dat[j][0] += x
    while j >= 0:
        j = (j - 1) // 2
        k1 = j * 2 + 1
        k2 = j * 2 + 2
        if dat[k1][0] <= dat[k2][0]:
            dat[j][0] = dat[k2][0]
            dat[j][1] = dat[k2][1]
        else:
            dat[j][0] = dat[k1][0]
            dat[j][1] = dat[k1][1]
            
def make():
    for i in reversed(range(n-1)):
        k1 = i * 2 + 1
        k2 = i * 2 + 2
        if dat[k1][0] <= dat[k2][0]:
            k = k2
        else:
            k = k1
        dat[i][0] = dat[k][0]
        dat[i][1] = dat[k][1]

def get():
    return dat[0][1]

make()
Q = int(input())
for _ in range(Q):
    t,x,y = map(int,input().split())
    if t == 1:
        add(x,y)
    elif t == 2:
        add(x,-y)
    else:
        print(get())

    
0