結果

問題 No.844 split game
ユーザー H3PO4H3PO4
提出日時 2021-02-22 08:35:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 653 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 35,440 KB
最終ジャッジ日時 2023-10-20 09:52:47
合計ジャッジ時間 16,704 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 257 ms
19,856 KB
testcase_01 AC 295 ms
24,652 KB
testcase_02 AC 493 ms
27,284 KB
testcase_03 AC 434 ms
27,600 KB
testcase_04 AC 219 ms
18,336 KB
testcase_05 AC 557 ms
31,548 KB
testcase_06 AC 194 ms
18,008 KB
testcase_07 AC 224 ms
21,468 KB
testcase_08 AC 118 ms
14,648 KB
testcase_09 AC 382 ms
21,816 KB
testcase_10 AC 578 ms
30,780 KB
testcase_11 AC 591 ms
33,564 KB
testcase_12 AC 393 ms
21,372 KB
testcase_13 AC 240 ms
17,412 KB
testcase_14 AC 296 ms
22,808 KB
testcase_15 AC 634 ms
35,440 KB
testcase_16 AC 648 ms
35,440 KB
testcase_17 AC 653 ms
35,440 KB
testcase_18 AC 630 ms
35,440 KB
testcase_19 AC 650 ms
35,440 KB
testcase_20 AC 635 ms
35,440 KB
testcase_21 AC 643 ms
35,440 KB
testcase_22 AC 651 ms
35,440 KB
testcase_23 AC 47 ms
10,992 KB
testcase_24 AC 73 ms
12,152 KB
testcase_25 AC 50 ms
10,848 KB
testcase_26 AC 43 ms
10,872 KB
testcase_27 AC 61 ms
11,228 KB
testcase_28 AC 42 ms
11,004 KB
testcase_29 AC 68 ms
12,004 KB
testcase_30 AC 74 ms
12,128 KB
testcase_31 AC 62 ms
11,404 KB
testcase_32 AC 41 ms
10,900 KB
testcase_33 AC 75 ms
11,284 KB
testcase_34 AC 55 ms
10,748 KB
testcase_35 AC 87 ms
11,428 KB
testcase_36 AC 64 ms
10,916 KB
testcase_37 AC 113 ms
12,084 KB
testcase_38 AC 195 ms
15,124 KB
testcase_39 AC 372 ms
20,140 KB
testcase_40 AC 181 ms
18,428 KB
testcase_41 AC 29 ms
10,024 KB
testcase_42 AC 29 ms
10,024 KB
testcase_43 AC 28 ms
10,024 KB
testcase_44 AC 29 ms
10,024 KB
testcase_45 AC 29 ms
10,024 KB
testcase_46 AC 29 ms
10,024 KB
testcase_47 AC 28 ms
10,024 KB
testcase_48 AC 29 ms
10,024 KB
testcase_49 AC 28 ms
10,024 KB
testcase_50 AC 28 ms
10,024 KB
testcase_51 AC 29 ms
10,024 KB
testcase_52 AC 29 ms
10,024 KB
testcase_53 AC 28 ms
10,024 KB
testcase_54 AC 31 ms
10,024 KB
testcase_55 AC 29 ms
10,024 KB
testcase_56 AC 28 ms
10,024 KB
testcase_57 AC 29 ms
10,024 KB
testcase_58 AC 33 ms
10,024 KB
testcase_59 AC 29 ms
10,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, A = map(int, input().split())
sections = [[] for _ in range(N)]
for _ in range(M):
    l, r, p = map(int, input().split())
    l -= 1
    sections[l].append((r, p))

dp = [-10 ** 9 - 5] * (N + 1)
dp[0] = 0
cur_max = 0
for i, s in enumerate(sections):
    dp[i] = max(dp[i], cur_max - A)
    cur = dp[i]
    for r, p in s:
        dp[r] = max(dp[r], cur + p - (A if r != N else 0))
    cur_max = max(cur_max, cur)

print(max(dp))
0