結果

問題 No.631 Noelちゃんと電車旅行
ユーザー mkawa2mkawa2
提出日時 2020-07-09 14:59:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,849 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 94,928 KB
最終ジャッジ日時 2024-04-16 10:02:22
合計ジャッジ時間 21,583 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 924 ms
85,648 KB
testcase_01 AC 1,670 ms
94,876 KB
testcase_02 AC 1,661 ms
94,928 KB
testcase_03 WA -
testcase_04 AC 1,641 ms
94,592 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 360 ms
85,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 864 ms
87,296 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 825 ms
84,328 KB
testcase_16 AC 58 ms
63,616 KB
testcase_17 AC 60 ms
65,024 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 61 ms
65,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class LazySeg:
    def __init__(self, aa):
        inf = 10 ** 16
        n = 1 << (len(aa) - 1).bit_length()
        tree = [-inf] * (2 * n)
        lazy = [0] * (2 * n)
        tree[n:n + len(aa)] = aa
        for u in range(n - 1, 0, -1): tree[u] = max(tree[u * 2], tree[u * 2 + 1])
        self.tree = tree
        self.lazy = lazy
        self.n = n
        self.inf = inf

    def add(self, l, r, a, u=1, tl=0, tr=-1):
        if tr == -1: tr = self.n
        self._eval(u)
        if r <= tl or tr <= l: return
        if l <= tl and tr <= r:
            self.lazy[u] += a
            self._eval(u)
            return
        tm = (tl + tr) // 2
        self.add(l, r, a, u * 2, tl, tm)
        self.add(l, r, a, u * 2 + 1, tm, tr)
        self.tree[u]=max(self.tree[u*2],self.tree[u*2+1])

    def max(self, l, r, u=1, tl=0, tr=-1):
        if tr == -1: tr = self.n
        self._eval(u)
        if r <= tl or tr <= l: return -self.inf
        if l <= tl and tr <= r:return self.tree[u]
        tm = (tl + tr) // 2
        res=max(self.max(l, r, u * 2, tl, tm),self.max(l, r, u * 2 + 1, tm, tr))
        return res

    def _eval(self, u):
        self.tree[u]+=self.lazy[u]
        if u<n:
            self.lazy[u * 2] += self.lazy[u]
            self.lazy[u * 2 + 1] += self.lazy[u]
        self.lazy[u]=0

n=II()
tt=LI()
for i in range(n-1):tt[i]-=i*3
st=LazySeg(tt)
mn=3*(n-1)
for _ in range(II()):
    l,r,d=MI()
    st.add(l-1,r,d)
    print(mn+st.max(0,n-1))
0