結果

問題 No.844 split game
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-19 01:24:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 88,248 KB
最終ジャッジ日時 2023-10-21 08:36:20
合計ジャッジ時間 7,539 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
79,876 KB
testcase_01 AC 92 ms
83,268 KB
testcase_02 AC 142 ms
82,844 KB
testcase_03 AC 109 ms
82,452 KB
testcase_04 AC 92 ms
79,768 KB
testcase_05 AC 162 ms
85,752 KB
testcase_06 AC 96 ms
79,660 KB
testcase_07 AC 91 ms
81,552 KB
testcase_08 AC 94 ms
78,384 KB
testcase_09 AC 108 ms
78,032 KB
testcase_10 AC 174 ms
85,548 KB
testcase_11 AC 165 ms
86,944 KB
testcase_12 AC 109 ms
77,896 KB
testcase_13 AC 91 ms
77,868 KB
testcase_14 AC 119 ms
82,336 KB
testcase_15 AC 154 ms
87,612 KB
testcase_16 AC 176 ms
88,224 KB
testcase_17 AC 169 ms
87,632 KB
testcase_18 AC 156 ms
87,588 KB
testcase_19 AC 178 ms
88,248 KB
testcase_20 AC 157 ms
87,588 KB
testcase_21 AC 166 ms
87,660 KB
testcase_22 AC 168 ms
87,608 KB
testcase_23 AC 66 ms
70,568 KB
testcase_24 AC 76 ms
74,680 KB
testcase_25 AC 58 ms
66,328 KB
testcase_26 AC 59 ms
66,416 KB
testcase_27 AC 61 ms
68,412 KB
testcase_28 AC 51 ms
64,032 KB
testcase_29 AC 73 ms
73,412 KB
testcase_30 AC 73 ms
73,196 KB
testcase_31 AC 73 ms
74,036 KB
testcase_32 AC 58 ms
66,428 KB
testcase_33 AC 53 ms
66,284 KB
testcase_34 AC 50 ms
64,232 KB
testcase_35 AC 54 ms
68,332 KB
testcase_36 AC 52 ms
66,284 KB
testcase_37 AC 57 ms
70,380 KB
testcase_38 AC 78 ms
77,652 KB
testcase_39 AC 131 ms
80,648 KB
testcase_40 AC 72 ms
74,672 KB
testcase_41 AC 38 ms
53,380 KB
testcase_42 AC 39 ms
53,380 KB
testcase_43 AC 37 ms
53,380 KB
testcase_44 AC 37 ms
53,380 KB
testcase_45 AC 37 ms
53,380 KB
testcase_46 AC 38 ms
53,380 KB
testcase_47 AC 36 ms
53,380 KB
testcase_48 AC 38 ms
53,380 KB
testcase_49 AC 37 ms
53,380 KB
testcase_50 AC 37 ms
53,380 KB
testcase_51 AC 37 ms
53,380 KB
testcase_52 AC 38 ms
53,380 KB
testcase_53 AC 38 ms
53,380 KB
testcase_54 AC 37 ms
53,380 KB
testcase_55 AC 37 ms
53,380 KB
testcase_56 AC 38 ms
53,380 KB
testcase_57 AC 38 ms
53,380 KB
testcase_58 AC 38 ms
53,380 KB
testcase_59 AC 37 ms
53,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M, A = map(int, input().split())
LX = [[] for _ in range(N + 1)]
for _ in range(M):
    l, r, x = map(int, input().split())
    LX[r].append((l, x))

dp0 = [0] * (N + 1)
dp1 = [0] * (N + 1)

tmp = 0
for r in range(N+1):
    # 線を引く
    get = 0
    for l, x in LX[r]:
        get = max(get, dp0[l - 1] + x)
        if l == 1:
            get = max(get, dp1[l - 1] + x)
        else:
            get = max(get, dp1[l - 1] + x - A)
    if r < N:
        dp0[r] = get - A
    else:
        dp0[r] = get

    # 線を引かない
    tmp = max(tmp, dp0[r-1], dp1[r-1])
    dp1[r] = tmp

print(max(dp0[N], dp1[N]))
0