結果

問題 No.844 split game
ユーザー Coki628Coki628
提出日時 2020-08-14 16:07:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 1,195 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 89,272 KB
最終ジャッジ日時 2024-04-18 18:41:21
合計ジャッジ時間 7,311 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
81,044 KB
testcase_01 AC 98 ms
82,812 KB
testcase_02 AC 144 ms
83,728 KB
testcase_03 AC 125 ms
84,808 KB
testcase_04 AC 94 ms
79,828 KB
testcase_05 AC 174 ms
87,928 KB
testcase_06 AC 100 ms
79,772 KB
testcase_07 AC 90 ms
82,216 KB
testcase_08 AC 91 ms
78,880 KB
testcase_09 AC 121 ms
80,496 KB
testcase_10 AC 188 ms
86,472 KB
testcase_11 AC 182 ms
88,872 KB
testcase_12 AC 116 ms
79,628 KB
testcase_13 AC 109 ms
79,380 KB
testcase_14 AC 127 ms
83,024 KB
testcase_15 AC 177 ms
89,116 KB
testcase_16 AC 191 ms
88,920 KB
testcase_17 AC 188 ms
88,860 KB
testcase_18 AC 183 ms
88,768 KB
testcase_19 AC 174 ms
89,272 KB
testcase_20 AC 173 ms
88,728 KB
testcase_21 AC 176 ms
88,476 KB
testcase_22 AC 186 ms
88,956 KB
testcase_23 AC 70 ms
74,912 KB
testcase_24 AC 80 ms
77,776 KB
testcase_25 AC 59 ms
73,056 KB
testcase_26 AC 63 ms
71,488 KB
testcase_27 AC 66 ms
74,432 KB
testcase_28 AC 49 ms
66,068 KB
testcase_29 AC 82 ms
77,900 KB
testcase_30 AC 79 ms
77,676 KB
testcase_31 AC 78 ms
76,568 KB
testcase_32 AC 59 ms
69,000 KB
testcase_33 AC 56 ms
72,100 KB
testcase_34 AC 53 ms
68,752 KB
testcase_35 AC 56 ms
73,152 KB
testcase_36 AC 54 ms
70,056 KB
testcase_37 AC 68 ms
76,844 KB
testcase_38 AC 84 ms
77,320 KB
testcase_39 AC 125 ms
81,296 KB
testcase_40 AC 88 ms
80,804 KB
testcase_41 AC 37 ms
52,580 KB
testcase_42 AC 36 ms
52,792 KB
testcase_43 AC 36 ms
53,616 KB
testcase_44 AC 36 ms
53,064 KB
testcase_45 AC 37 ms
52,328 KB
testcase_46 AC 34 ms
53,000 KB
testcase_47 AC 36 ms
52,568 KB
testcase_48 AC 35 ms
53,368 KB
testcase_49 AC 35 ms
53,120 KB
testcase_50 AC 37 ms
52,604 KB
testcase_51 AC 36 ms
53,908 KB
testcase_52 AC 36 ms
53,012 KB
testcase_53 AC 35 ms
52,760 KB
testcase_54 AC 34 ms
52,892 KB
testcase_55 AC 38 ms
53,160 KB
testcase_56 AC 36 ms
52,676 KB
testcase_57 AC 37 ms
52,900 KB
testcase_58 AC 33 ms
52,880 KB
testcase_59 AC 37 ms
54,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N, M, K = MAP()

RL = [[] for i in range(N+1)]
for i in range(M):
    l, r, p = MAP()
    l -= 1
    RL[r].append((l, p))

dp0 = [-INF] * (N+1)
dp1 = [-INF] * (N+1)
dp0[0] = dp1[0] = 0
for r in range(1, N+1):
    dp0[r] = max(dp0[r-1], dp1[r-1])
    for l, p in RL[r]:
        if r == N:
            dp1[r] = max(dp1[r], dp0[l] + p-K)
            dp1[r] = max(dp1[r], dp1[l] + p)
        else:
            dp1[r] = max(dp1[r], dp0[l] + p-K*2)
            dp1[r] = max(dp1[r], dp1[l] + p-K)
ans = max(dp0[N], dp1[N])
print(ans)
0