結果

問題 No.844 split game
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-07-07 21:36:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 82,108 KB
実行使用メモリ 96,452 KB
最終ジャッジ日時 2024-04-15 14:31:36
合計ジャッジ時間 11,669 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
83,264 KB
testcase_01 AC 160 ms
90,884 KB
testcase_02 AC 225 ms
85,244 KB
testcase_03 AC 201 ms
92,064 KB
testcase_04 AC 144 ms
82,816 KB
testcase_05 AC 264 ms
93,384 KB
testcase_06 AC 151 ms
83,840 KB
testcase_07 AC 150 ms
90,732 KB
testcase_08 AC 130 ms
80,528 KB
testcase_09 AC 194 ms
81,536 KB
testcase_10 AC 262 ms
90,240 KB
testcase_11 AC 269 ms
96,084 KB
testcase_12 AC 196 ms
80,896 KB
testcase_13 AC 157 ms
79,232 KB
testcase_14 AC 175 ms
88,192 KB
testcase_15 AC 269 ms
95,440 KB
testcase_16 AC 288 ms
96,204 KB
testcase_17 AC 283 ms
96,452 KB
testcase_18 AC 270 ms
95,496 KB
testcase_19 AC 286 ms
95,688 KB
testcase_20 AC 267 ms
95,620 KB
testcase_21 AC 287 ms
96,204 KB
testcase_22 AC 297 ms
96,264 KB
testcase_23 AC 105 ms
77,440 KB
testcase_24 AC 124 ms
77,952 KB
testcase_25 AC 98 ms
77,156 KB
testcase_26 AC 97 ms
77,184 KB
testcase_27 AC 99 ms
76,916 KB
testcase_28 AC 80 ms
70,144 KB
testcase_29 AC 116 ms
77,952 KB
testcase_30 AC 107 ms
78,080 KB
testcase_31 AC 106 ms
77,440 KB
testcase_32 AC 98 ms
77,056 KB
testcase_33 AC 97 ms
76,500 KB
testcase_34 AC 91 ms
76,800 KB
testcase_35 AC 97 ms
76,648 KB
testcase_36 AC 94 ms
76,544 KB
testcase_37 AC 103 ms
76,600 KB
testcase_38 AC 137 ms
78,848 KB
testcase_39 AC 212 ms
81,792 KB
testcase_40 AC 134 ms
86,300 KB
testcase_41 AC 48 ms
53,504 KB
testcase_42 AC 48 ms
53,504 KB
testcase_43 AC 48 ms
53,360 KB
testcase_44 AC 47 ms
53,504 KB
testcase_45 AC 48 ms
53,888 KB
testcase_46 AC 51 ms
53,760 KB
testcase_47 AC 47 ms
53,248 KB
testcase_48 AC 48 ms
53,504 KB
testcase_49 AC 51 ms
53,504 KB
testcase_50 AC 48 ms
53,504 KB
testcase_51 AC 47 ms
53,376 KB
testcase_52 AC 50 ms
53,888 KB
testcase_53 AC 47 ms
53,504 KB
testcase_54 AC 47 ms
53,504 KB
testcase_55 AC 48 ms
53,888 KB
testcase_56 AC 46 ms
53,632 KB
testcase_57 AC 48 ms
54,144 KB
testcase_58 AC 48 ms
54,016 KB
testcase_59 AC 51 ms
54,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

n, m, a = map(int, input().split())
e = collections.defaultdict(list)
for _ in range(m):
    l, r, p = map(int, input().split())
    e[r].append((l - 1, p))


dp = [-float('inf')] * (n + 1)
dp[0] = 0
maximum = 0
for r in range(1, n + 1):
    dp[r] = max(dp[r], maximum - a)
    for l, p in e[r]:
        if r == n:
            dp[r] = max(dp[r], dp[l] + p) 
        else:
            dp[r] = max(dp[r], dp[l] + p - a) 
    maximum = max(maximum, dp[r])

print(maximum)
0