結果

問題 No.844 split game
ユーザー ttrttr
提出日時 2020-02-19 22:52:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 743 ms / 2,000 ms
コード長 719 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 35,228 KB
最終ジャッジ日時 2024-04-17 06:10:12
合計ジャッジ時間 18,042 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 304 ms
20,636 KB
testcase_01 AC 287 ms
21,248 KB
testcase_02 AC 612 ms
30,832 KB
testcase_03 AC 456 ms
26,856 KB
testcase_04 AC 240 ms
18,820 KB
testcase_05 AC 650 ms
32,204 KB
testcase_06 AC 209 ms
17,972 KB
testcase_07 AC 215 ms
18,432 KB
testcase_08 AC 126 ms
14,720 KB
testcase_09 AC 471 ms
26,768 KB
testcase_10 AC 686 ms
33,016 KB
testcase_11 AC 672 ms
33,148 KB
testcase_12 AC 496 ms
26,524 KB
testcase_13 AC 336 ms
20,204 KB
testcase_14 AC 316 ms
21,612 KB
testcase_15 AC 737 ms
34,932 KB
testcase_16 AC 743 ms
35,028 KB
testcase_17 AC 726 ms
35,224 KB
testcase_18 AC 723 ms
35,032 KB
testcase_19 AC 739 ms
35,228 KB
testcase_20 AC 735 ms
34,968 KB
testcase_21 AC 734 ms
35,032 KB
testcase_22 AC 724 ms
35,032 KB
testcase_23 AC 51 ms
11,648 KB
testcase_24 AC 78 ms
12,672 KB
testcase_25 AC 56 ms
11,904 KB
testcase_26 AC 44 ms
11,392 KB
testcase_27 AC 68 ms
12,288 KB
testcase_28 AC 41 ms
11,392 KB
testcase_29 AC 69 ms
12,416 KB
testcase_30 AC 77 ms
12,672 KB
testcase_31 AC 68 ms
12,544 KB
testcase_32 AC 41 ms
11,264 KB
testcase_33 AC 89 ms
12,416 KB
testcase_34 AC 63 ms
11,776 KB
testcase_35 AC 103 ms
12,928 KB
testcase_36 AC 74 ms
12,032 KB
testcase_37 AC 136 ms
14,080 KB
testcase_38 AC 235 ms
18,176 KB
testcase_39 AC 499 ms
25,864 KB
testcase_40 AC 185 ms
16,812 KB
testcase_41 AC 29 ms
10,880 KB
testcase_42 AC 28 ms
10,880 KB
testcase_43 AC 30 ms
11,008 KB
testcase_44 AC 29 ms
10,752 KB
testcase_45 AC 29 ms
10,880 KB
testcase_46 AC 30 ms
11,008 KB
testcase_47 AC 29 ms
10,880 KB
testcase_48 AC 29 ms
10,880 KB
testcase_49 AC 30 ms
10,880 KB
testcase_50 AC 30 ms
10,880 KB
testcase_51 AC 31 ms
10,880 KB
testcase_52 AC 30 ms
11,008 KB
testcase_53 AC 29 ms
10,752 KB
testcase_54 AC 28 ms
10,880 KB
testcase_55 AC 29 ms
11,008 KB
testcase_56 AC 30 ms
10,880 KB
testcase_57 AC 30 ms
10,880 KB
testcase_58 AC 30 ms
10,880 KB
testcase_59 AC 29 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,A = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(M)]

from operator import itemgetter

L.sort(key=itemgetter(1))
dp0 = [0]*(N+1)
dp1 = [0]*(N+1)
j = 0
for i in range(1, N+1):
    dp0[i] = max(dp0[i-1], dp1[i-1])
    dp1[i] = dp0[i]-A
    while j < M and L[j][1] == i:
        if L[j][0] == 1 and L[j][1] == N:
            dp1[i] = max(dp1[i], L[j][2])
        elif L[j][0] == 1:
            dp1[i] = max(dp1[i], L[j][2]-A)
        elif L[j][1] == N:
            dp1[i] = max(dp1[i], dp1[L[j][0]-1]+L[j][2], dp0[L[j][0]-1]+L[j][2]-A)
        else:
            dp1[i] = max(dp1[i], dp1[L[j][0]-1]+L[j][2]-A, dp0[L[j][0]-1]+L[j][2]-2*A)
        j += 1

print(max(max(dp0), max(dp1)))
0