結果
問題 | No.844 split game |
ユーザー | roaris |
提出日時 | 2019-12-25 15:35:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,555 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 81,692 KB |
実行使用メモリ | 92,076 KB |
最終ジャッジ日時 | 2023-10-25 07:57:25 |
合計ジャッジ時間 | 14,924 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 240 ms
81,996 KB |
testcase_07 | AC | 206 ms
81,836 KB |
testcase_08 | WA | - |
testcase_09 | AC | 380 ms
86,884 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 381 ms
87,068 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 357 ms
90,468 KB |
testcase_16 | AC | 516 ms
92,076 KB |
testcase_17 | AC | 480 ms
91,940 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 476 ms
91,676 KB |
testcase_22 | AC | 480 ms
91,844 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 87 ms
76,612 KB |
testcase_27 | AC | 142 ms
77,692 KB |
testcase_28 | AC | 67 ms
73,816 KB |
testcase_29 | WA | - |
testcase_30 | AC | 142 ms
78,392 KB |
testcase_31 | WA | - |
testcase_32 | AC | 80 ms
76,344 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 140 ms
78,152 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 38 ms
53,460 KB |
testcase_42 | AC | 37 ms
53,460 KB |
testcase_43 | AC | 37 ms
53,460 KB |
testcase_44 | AC | 37 ms
53,460 KB |
testcase_45 | AC | 36 ms
53,460 KB |
testcase_46 | AC | 37 ms
53,460 KB |
testcase_47 | AC | 36 ms
53,460 KB |
testcase_48 | AC | 37 ms
53,460 KB |
testcase_49 | AC | 37 ms
53,460 KB |
testcase_50 | AC | 37 ms
53,460 KB |
testcase_51 | AC | 38 ms
53,460 KB |
testcase_52 | AC | 37 ms
53,460 KB |
testcase_53 | WA | - |
testcase_54 | AC | 37 ms
53,460 KB |
testcase_55 | AC | 38 ms
53,460 KB |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | AC | 38 ms
53,460 KB |
ソースコード
import sys input = sys.stdin.readline class SegmentTree: def __init__(self, N, func, ele): n_ = 1 while n_<N: n_ *= 2 self.n = n_ self.func = func self.ele = ele self.arr = [self.ele]*(2*self.n-1) def update(self, k, a): k += self.n-1 self.arr[k] = a while k>0: k = (k-1)//2 self.arr[k] = self.func(self.arr[2*k+1], self.arr[2*k+2]) def query(self, l, r): L, R = l+self.n, r+self.n res = self.ele while L<R: if R&1: R -= 1 res = self.func(res, self.arr[R-1]) if L&1: res = self.func(res, self.arr[L-1]) L += 1 L >>= 1 R >>= 1 return res N, M, A = map(int, input().split()) lrp = [tuple(map(int, input().split())) for _ in range(M)] lrp.sort(key=lambda k: k[0]) dp = [0]*N st = SegmentTree(N, max, -10**18) for i in range(N): st.update(i, 0) ans = 0 for li, ri, pi in lrp: li -= 1 ri -= 1 if li==0: dp[ri] = max(dp[ri], pi-A) else: if dp[li-1]>0: dp[ri] = max(dp[ri], dp[li-1]+pi-A) else: dp[ri] = max(dp[ri], pi-2*A) if li>1: dp[ri] = max(dp[ri], st.query(0, li-1)+pi-2*A) if ri==N-1: dp[ri] += A st.update(ri, dp[ri]) ans = max(ans, dp[ri]) print(ans)