結果

問題 No.844 split game
ユーザー titiatitia
提出日時 2019-06-28 22:37:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 761 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 105,572 KB
最終ジャッジ日時 2023-09-14 22:23:03
合計ジャッジ時間 10,595 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
88,584 KB
testcase_01 AC 140 ms
84,836 KB
testcase_02 AC 190 ms
90,296 KB
testcase_03 AC 182 ms
96,000 KB
testcase_04 AC 128 ms
81,588 KB
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 AC 224 ms
105,356 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 222 ms
105,216 KB
testcase_19 WA -
testcase_20 AC 222 ms
105,224 KB
testcase_21 AC 232 ms
105,524 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 90 ms
76,732 KB
testcase_27 WA -
testcase_28 AC 84 ms
76,868 KB
testcase_29 AC 105 ms
79,440 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 89 ms
76,972 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 101 ms
78,668 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 117 ms
80,912 KB
testcase_39 AC 167 ms
95,512 KB
testcase_40 AC 110 ms
80,076 KB
testcase_41 AC 71 ms
71,192 KB
testcase_42 AC 71 ms
71,420 KB
testcase_43 AC 70 ms
71,280 KB
testcase_44 AC 71 ms
71,284 KB
testcase_45 AC 71 ms
71,312 KB
testcase_46 AC 71 ms
71,296 KB
testcase_47 AC 71 ms
71,344 KB
testcase_48 AC 71 ms
71,288 KB
testcase_49 AC 72 ms
71,200 KB
testcase_50 AC 71 ms
71,376 KB
testcase_51 AC 72 ms
71,304 KB
testcase_52 AC 70 ms
71,000 KB
testcase_53 WA -
testcase_54 AC 72 ms
71,324 KB
testcase_55 AC 73 ms
71,272 KB
testcase_56 AC 71 ms
71,264 KB
testcase_57 AC 71 ms
71,280 KB
testcase_58 AC 72 ms
71,328 KB
testcase_59 AC 72 ms
71,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

for i in range(M):
    L[i][1]+=1
    
LLIST=[[] for i in range(N+2)]

for x,y,z in L:
    LLIST[x].append([y,z])

DP=[0]*(N+2)
USE=[0]*(N+2)
USE[1]=1
USE[N+1]=1

for i in range(N+2):
    if DP[i-1]>=DP[i]:
        DP[i]=DP[i-1]
        USE[i]=0
    USE[1]=1
    
    for y,z in LLIST[i]:
        if USE[i]==1 and y==N+1:
            DP[y]=max(DP[y],DP[i]+z)

        elif USE[i]==0 and y==N+1:
            DP[y]=max(DP[y],DP[i]+z-A)

        elif USE[i]==1:
            DP[y]=max(DP[y],DP[i]+z-A)
            USE[y]=1

        elif USE[i]==0:
            DP[y]=max(DP[y],DP[i]+z-2*A)
            USE[y]=1

    #print(DP)

print(DP[-1])
0