結果

問題 No.844 split game
ユーザー terasaterasa
提出日時 2022-06-28 23:49:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,307 bytes
コンパイル時間 779 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 88,220 KB
最終ジャッジ日時 2024-05-01 14:12:58
合計ジャッジ時間 9,552 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 62 ms
72,832 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 86 ms
77,604 KB
testcase_39 AC 105 ms
79,872 KB
testcase_40 AC 97 ms
80,316 KB
testcase_41 AC 44 ms
54,912 KB
testcase_42 AC 45 ms
54,784 KB
testcase_43 WA -
testcase_44 AC 44 ms
54,784 KB
testcase_45 AC 44 ms
54,272 KB
testcase_46 AC 43 ms
54,528 KB
testcase_47 AC 44 ms
54,784 KB
testcase_48 WA -
testcase_49 AC 44 ms
54,272 KB
testcase_50 AC 44 ms
54,784 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 44 ms
54,528 KB
testcase_54 AC 44 ms
54,400 KB
testcase_55 AC 44 ms
54,912 KB
testcase_56 AC 44 ms
54,784 KB
testcase_57 AC 49 ms
54,528 KB
testcase_58 AC 47 ms
54,400 KB
testcase_59 AC 44 ms
54,912 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)
for i in range(N):
    for j, p in E[i]:
        if i == 0 and j == N:
            dp[j] = max(dp[j], p)
        elif i == 0:
            dp[j] = max(dp[j], p - A)
        elif j == N:
            dp[j] = max(dp[j], dp[i] + p, p - A)
        else:
            dp[j] = max(dp[j], dp[i] + p - A, p - 2 * A)
    dp[i + 1] = max(dp[i + 1], dp[i])
print(dp[N])
0