結果

問題 No.1705 Mode of long array
ユーザー gr1msl3ygr1msl3y
提出日時 2021-10-09 20:28:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,553 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 100,784 KB
最終ジャッジ日時 2023-10-11 10:53:05
合計ジャッジ時間 22,973 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,348 KB
testcase_01 AC 70 ms
71,148 KB
testcase_02 AC 69 ms
71,580 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 384 ms
99,068 KB
testcase_14 AC 306 ms
89,520 KB
testcase_15 AC 295 ms
85,068 KB
testcase_16 AC 320 ms
86,532 KB
testcase_17 AC 277 ms
83,984 KB
testcase_18 AC 268 ms
83,644 KB
testcase_19 AC 354 ms
89,052 KB
testcase_20 AC 287 ms
85,040 KB
testcase_21 AC 331 ms
96,440 KB
testcase_22 AC 423 ms
99,848 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

class SegmentTree():
    def __init__(self, n, unit, f, A=None):
        self.s = 2**(n-1).bit_length()
        self.size = 2*self.s
        self.node = [unit]*self.size
        self.op = f
        self.UNIT = unit
        if A:
            for i in range(n):
                self.node[self.s+i] = A[i]
            for i in range(self.s-1, -1, -1):
                self.node[i] = self.op(self.node[2*i], self.node[2*i+1])

    def update(self, i, v):
        i += self.s
        self.node[i] = v
        while i > 0:
            i >>= 1
            self.node[i] = self.op(self.node[2*i], self.node[2*i+1])

    def get(self, l, r):
        vl, vr = self.UNIT, self.UNIT
        l += self.s
        r += self.s
        while l < r:
            if l & 1:
                vl = self.op(self.node[l], vl)
                l += 1
            if r & 1:
                r -= 1
                vr = self.op(vr, self.node[r])
            l >>= 1
            r >>= 1
        return self.op(vl, vr)


def op(x, y):
    return y if y[0] >= x[0] else x


N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [[0]*2 for _ in range(M+1)]
for i in range(M):
    B[i+1] = [A[i], i+1]

arr = SegmentTree(M+1, [0, 0], op, B)
ans = []
Q = int(input())
for _ in range(Q):
    t, x, y = map(int, input().split())
    if t == 1:
        v = arr.get(x, x+1)[0]
        arr.update(x, [v+y, x])
    elif t == 2:
        v = arr.get(x, x+1)[0]
        arr.update(x, [v-y, x])
    else:
        z = arr.get(0, M+1)[1]
        ans.append(z)

print(*ans, sep='\n')
0