結果

問題 No.844 split game
ユーザー terasaterasa
提出日時 2022-06-29 00:04:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 1,197 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,212 KB
実行使用メモリ 89,096 KB
最終ジャッジ日時 2024-05-01 14:27:43
合計ジャッジ時間 8,296 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
79,588 KB
testcase_01 AC 107 ms
82,520 KB
testcase_02 AC 150 ms
82,612 KB
testcase_03 AC 134 ms
84,360 KB
testcase_04 AC 107 ms
79,544 KB
testcase_05 AC 181 ms
86,028 KB
testcase_06 AC 98 ms
80,224 KB
testcase_07 AC 99 ms
82,152 KB
testcase_08 AC 104 ms
79,276 KB
testcase_09 AC 131 ms
80,596 KB
testcase_10 AC 202 ms
85,832 KB
testcase_11 AC 190 ms
87,788 KB
testcase_12 AC 136 ms
79,724 KB
testcase_13 AC 105 ms
78,116 KB
testcase_14 AC 150 ms
83,144 KB
testcase_15 AC 188 ms
87,652 KB
testcase_16 AC 202 ms
88,172 KB
testcase_17 AC 194 ms
87,884 KB
testcase_18 AC 186 ms
87,940 KB
testcase_19 AC 223 ms
89,096 KB
testcase_20 AC 188 ms
88,228 KB
testcase_21 AC 191 ms
87,800 KB
testcase_22 AC 187 ms
88,092 KB
testcase_23 AC 72 ms
72,180 KB
testcase_24 AC 94 ms
77,884 KB
testcase_25 AC 71 ms
72,016 KB
testcase_26 AC 68 ms
70,192 KB
testcase_27 AC 74 ms
74,632 KB
testcase_28 AC 58 ms
65,800 KB
testcase_29 AC 89 ms
77,832 KB
testcase_30 AC 85 ms
77,660 KB
testcase_31 AC 87 ms
77,088 KB
testcase_32 AC 68 ms
68,852 KB
testcase_33 AC 67 ms
72,500 KB
testcase_34 AC 66 ms
69,388 KB
testcase_35 AC 73 ms
72,980 KB
testcase_36 AC 66 ms
71,716 KB
testcase_37 AC 78 ms
77,172 KB
testcase_38 AC 89 ms
77,620 KB
testcase_39 AC 120 ms
79,956 KB
testcase_40 AC 100 ms
80,552 KB
testcase_41 AC 47 ms
55,312 KB
testcase_42 AC 47 ms
54,876 KB
testcase_43 AC 47 ms
55,108 KB
testcase_44 AC 47 ms
55,492 KB
testcase_45 AC 47 ms
55,556 KB
testcase_46 AC 46 ms
55,268 KB
testcase_47 AC 47 ms
55,548 KB
testcase_48 AC 46 ms
55,948 KB
testcase_49 AC 47 ms
55,752 KB
testcase_50 AC 46 ms
55,200 KB
testcase_51 AC 46 ms
54,992 KB
testcase_52 AC 47 ms
55,204 KB
testcase_53 AC 48 ms
55,264 KB
testcase_54 AC 47 ms
56,320 KB
testcase_55 AC 46 ms
55,072 KB
testcase_56 AC 46 ms
54,952 KB
testcase_57 AC 48 ms
54,992 KB
testcase_58 AC 47 ms
55,592 KB
testcase_59 AC 48 ms
55,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


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

INF = 1 << 50
dp = [-INF] * (N + 1)
dp[0] = 0
ma = 0
for i in range(N):
    for j, p in E[i]:
        if j == N:
            dp[j] = max(dp[j], dp[i] + p, ma + p - A)
        else:
            dp[j] = max(dp[j], dp[i] + p - A, ma + p - 2 * A)
    ma = max(ma, dp[i])
print(max(dp))
0