結果

問題 No.844 split game
ユーザー maspymaspy
提出日時 2020-02-28 15:27:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 507 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 48,540 KB
最終ジャッジ日時 2024-04-21 17:34:16
合計ジャッジ時間 12,615 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 200 ms
26,460 KB
testcase_01 AC 222 ms
27,456 KB
testcase_02 AC 368 ms
42,980 KB
testcase_03 AC 317 ms
35,624 KB
testcase_04 AC 156 ms
23,024 KB
testcase_05 AC 429 ms
45,052 KB
testcase_06 AC 150 ms
21,604 KB
testcase_07 AC 181 ms
22,620 KB
testcase_08 AC 94 ms
16,552 KB
testcase_09 AC 281 ms
33,984 KB
testcase_10 AC 455 ms
45,052 KB
testcase_11 AC 456 ms
46,548 KB
testcase_12 AC 260 ms
33,668 KB
testcase_13 AC 173 ms
25,532 KB
testcase_14 AC 231 ms
27,528 KB
testcase_15 AC 466 ms
48,412 KB
testcase_16 AC 493 ms
48,404 KB
testcase_17 AC 504 ms
48,468 KB
testcase_18 AC 474 ms
48,536 KB
testcase_19 AC 476 ms
48,404 KB
testcase_20 AC 479 ms
48,536 KB
testcase_21 AC 507 ms
48,540 KB
testcase_22 AC 504 ms
48,280 KB
testcase_23 AC 43 ms
12,160 KB
testcase_24 AC 61 ms
13,808 KB
testcase_25 AC 44 ms
12,160 KB
testcase_26 AC 40 ms
11,776 KB
testcase_27 AC 51 ms
12,928 KB
testcase_28 AC 41 ms
11,648 KB
testcase_29 AC 56 ms
13,308 KB
testcase_30 AC 61 ms
13,808 KB
testcase_31 AC 51 ms
13,152 KB
testcase_32 AC 39 ms
11,520 KB
testcase_33 AC 56 ms
13,808 KB
testcase_34 AC 46 ms
12,544 KB
testcase_35 AC 63 ms
14,296 KB
testcase_36 AC 49 ms
12,928 KB
testcase_37 AC 81 ms
16,572 KB
testcase_38 AC 131 ms
20,976 KB
testcase_39 AC 263 ms
32,020 KB
testcase_40 AC 140 ms
19,748 KB
testcase_41 AC 31 ms
10,624 KB
testcase_42 AC 31 ms
10,624 KB
testcase_43 AC 32 ms
10,624 KB
testcase_44 AC 33 ms
10,624 KB
testcase_45 AC 30 ms
10,624 KB
testcase_46 AC 30 ms
10,496 KB
testcase_47 AC 34 ms
10,624 KB
testcase_48 AC 31 ms
10,624 KB
testcase_49 AC 31 ms
10,624 KB
testcase_50 AC 31 ms
10,624 KB
testcase_51 AC 30 ms
10,624 KB
testcase_52 AC 30 ms
10,624 KB
testcase_53 AC 30 ms
10,496 KB
testcase_54 AC 30 ms
10,624 KB
testcase_55 AC 30 ms
10,752 KB
testcase_56 AC 31 ms
10,624 KB
testcase_57 AC 30 ms
10,624 KB
testcase_58 AC 30 ms
10,624 KB
testcase_59 AC 31 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
N, M, A = map(int, readline().split())
m = map(int, read().split())
LRP = zip(m, m, m)

# %%
intervals = [[] for _ in range(N + 1)]
for l, r, p in LRP:
    intervals[r].append((l, p))


# %%
dp = [0] + [-A] * N
dp_cummax = [0] * (N + 1)

for r in range(1, N + 1):
    for l, p in intervals[r]:
        x = dp[l - 1] + p - A
        if dp[r] < x:
            dp[r] = x
        if l > 1:
            x = dp_cummax[l - 2] + p - 2 * A
            if dp[r] < x:
                dp[r] = x
    dp_cummax[r] = max(dp_cummax[r - 1], dp[r])

dp[N] += A

# %%
print(max(dp))
0