結果

問題 No.844 split game
ユーザー neterukunneterukun
提出日時 2019-06-28 23:24:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 326 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 93,928 KB
最終ジャッジ日時 2023-09-14 22:42:37
合計ジャッジ時間 12,813 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
82,372 KB
testcase_01 AC 151 ms
82,244 KB
testcase_02 AC 280 ms
91,172 KB
testcase_03 AC 214 ms
86,308 KB
testcase_04 AC 159 ms
81,540 KB
testcase_05 AC 326 ms
93,436 KB
testcase_06 AC 156 ms
81,168 KB
testcase_07 AC 135 ms
80,212 KB
testcase_08 AC 128 ms
78,912 KB
testcase_09 AC 234 ms
86,964 KB
testcase_10 AC 303 ms
91,456 KB
testcase_11 AC 310 ms
93,296 KB
testcase_12 AC 227 ms
86,956 KB
testcase_13 AC 186 ms
83,140 KB
testcase_14 AC 192 ms
82,988 KB
testcase_15 AC 294 ms
91,740 KB
testcase_16 AC 310 ms
93,180 KB
testcase_17 AC 305 ms
93,644 KB
testcase_18 AC 309 ms
91,808 KB
testcase_19 AC 326 ms
92,120 KB
testcase_20 AC 305 ms
91,808 KB
testcase_21 AC 318 ms
93,928 KB
testcase_22 AC 313 ms
93,712 KB
testcase_23 AC 107 ms
77,504 KB
testcase_24 AC 121 ms
78,008 KB
testcase_25 AC 104 ms
77,492 KB
testcase_26 AC 98 ms
76,212 KB
testcase_27 AC 108 ms
78,104 KB
testcase_28 AC 90 ms
76,004 KB
testcase_29 AC 115 ms
78,060 KB
testcase_30 AC 115 ms
78,016 KB
testcase_31 AC 117 ms
77,880 KB
testcase_32 AC 99 ms
76,404 KB
testcase_33 AC 108 ms
78,056 KB
testcase_34 AC 100 ms
77,712 KB
testcase_35 AC 110 ms
77,644 KB
testcase_36 AC 102 ms
77,928 KB
testcase_37 AC 122 ms
78,604 KB
testcase_38 AC 159 ms
81,468 KB
testcase_39 AC 244 ms
88,456 KB
testcase_40 AC 130 ms
79,180 KB
testcase_41 AC 78 ms
70,644 KB
testcase_42 AC 81 ms
71,028 KB
testcase_43 AC 80 ms
70,916 KB
testcase_44 AC 76 ms
70,948 KB
testcase_45 AC 76 ms
70,924 KB
testcase_46 AC 79 ms
71,052 KB
testcase_47 AC 78 ms
70,924 KB
testcase_48 AC 78 ms
71,028 KB
testcase_49 AC 79 ms
70,820 KB
testcase_50 AC 78 ms
70,660 KB
testcase_51 AC 78 ms
70,968 KB
testcase_52 AC 77 ms
70,664 KB
testcase_53 AC 78 ms
70,536 KB
testcase_54 AC 79 ms
70,852 KB
testcase_55 AC 78 ms
70,664 KB
testcase_56 AC 78 ms
70,920 KB
testcase_57 AC 78 ms
70,992 KB
testcase_58 AC 76 ms
70,924 KB
testcase_59 AC 78 ms
70,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter


input = sys.stdin.readline
n, m, a = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]

info = sorted(info, key = itemgetter(1)) + [[-1, -1, -1]] # 番兵

dp = [-float("inf")]*(n+1)
dp[0] = 0
end = 0
max_dp = 0
for i in range(1, n + 1):
    if info[end][1] == i:
        while True:
            #print(end, info[end][0], info[end][1])
            #print(max_dp)
            if i == n:
                dp[i] = max(dp[i], max_dp, dp[info[end][0] - 1] + info[end][2])
            else:
                dp[i] = max(dp[i], max_dp - a, dp[info[end][0] - 1] + info[end][2] - a)
            end += 1
            if info[end][1] != i:
                break
        max_dp = max(max_dp, dp[i])
    else:
        dp[i] = max_dp - a
print(max(dp))
0