結果

問題 No.844 split game
ユーザー mkawa2mkawa2
提出日時 2019-07-11 08:43:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 36,856 KB
最終ジャッジ日時 2024-04-24 19:53:13
合計ジャッジ時間 20,143 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 341 ms
21,120 KB
testcase_01 AC 258 ms
19,100 KB
testcase_02 AC 738 ms
33,284 KB
testcase_03 AC 509 ms
26,220 KB
testcase_04 AC 269 ms
18,816 KB
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 WA -
testcase_14 WA -
testcase_15 AC 820 ms
35,276 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 840 ms
35,204 KB
testcase_19 AC 827 ms
35,764 KB
testcase_20 AC 822 ms
35,144 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 39 ms
11,136 KB
testcase_27 WA -
testcase_28 AC 36 ms
11,008 KB
testcase_29 AC 72 ms
12,288 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 34 ms
11,008 KB
testcase_33 AC 90 ms
12,800 KB
testcase_34 AC 62 ms
11,904 KB
testcase_35 AC 103 ms
13,184 KB
testcase_36 AC 71 ms
12,160 KB
testcase_37 AC 140 ms
14,848 KB
testcase_38 AC 313 ms
19,712 KB
testcase_39 AC 619 ms
28,348 KB
testcase_40 AC 185 ms
15,836 KB
testcase_41 AC 28 ms
10,624 KB
testcase_42 AC 28 ms
10,752 KB
testcase_43 AC 27 ms
10,880 KB
testcase_44 AC 28 ms
10,752 KB
testcase_45 AC 28 ms
10,624 KB
testcase_46 AC 27 ms
10,880 KB
testcase_47 AC 28 ms
10,624 KB
testcase_48 WA -
testcase_49 AC 27 ms
10,752 KB
testcase_50 AC 27 ms
10,624 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 28 ms
10,752 KB
testcase_54 AC 27 ms
10,624 KB
testcase_55 AC 28 ms
10,624 KB
testcase_56 AC 27 ms
10,752 KB
testcase_57 AC 28 ms
10,752 KB
testcase_58 AC 27 ms
10,624 KB
testcase_59 AC 28 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter

def update(i, x):
    while i < n + 1:
        if x > bit[i]:
            bit[i] = x
        i += i & -i

def get(i):
    mx = 0
    while i > 0:
        if mx < bit[i]:
            mx = bit[i]
        i -= i & -i
    return mx

n, m, a = map(int, input().split())
ku = [list(map(int, input().split())) for _ in range(m)]
ku.sort(key=itemgetter(1))
bit = [0] * (n + 1)
dp = [-a] * (n + 1)
for l, r, p in ku:
    if l - 1:
        dp[r] = max(dp[l - 1] + p - a, get(l - 1) - 2 * a, dp[r])
        update(r, dp[r])
    else:
        dp[r] = max(p - a, dp[r])
        update(r, dp[r])
dp[-1] += a
print(max(dp))
0