結果

問題 No.844 split game
ユーザー titiatitia
提出日時 2019-06-28 22:11:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,059 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 102,104 KB
最終ジャッジ日時 2023-09-14 22:06:02
合計ジャッジ時間 11,997 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 179 ms
88,832 KB
testcase_01 AC 154 ms
84,316 KB
testcase_02 AC 286 ms
92,488 KB
testcase_03 AC 223 ms
94,656 KB
testcase_04 AC 148 ms
81,676 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 306 ms
101,736 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 306 ms
101,728 KB
testcase_19 WA -
testcase_20 AC 307 ms
101,552 KB
testcase_21 AC 310 ms
101,752 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 97 ms
77,016 KB
testcase_27 WA -
testcase_28 AC 85 ms
76,848 KB
testcase_29 AC 108 ms
79,628 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 89 ms
77,064 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 109 ms
78,708 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 163 ms
81,144 KB
testcase_39 AC 254 ms
94,704 KB
testcase_40 AC 129 ms
80,204 KB
testcase_41 AC 74 ms
71,360 KB
testcase_42 AC 72 ms
71,388 KB
testcase_43 AC 72 ms
71,532 KB
testcase_44 AC 74 ms
71,420 KB
testcase_45 AC 72 ms
71,360 KB
testcase_46 AC 72 ms
71,424 KB
testcase_47 AC 74 ms
71,356 KB
testcase_48 AC 73 ms
71,424 KB
testcase_49 AC 72 ms
71,356 KB
testcase_50 AC 73 ms
71,448 KB
testcase_51 AC 72 ms
71,172 KB
testcase_52 AC 71 ms
71,536 KB
testcase_53 WA -
testcase_54 AC 73 ms
71,436 KB
testcase_55 AC 73 ms
71,192 KB
testcase_56 AC 73 ms
71,536 KB
testcase_57 AC 70 ms
71,576 KB
testcase_58 AC 73 ms
71,468 KB
testcase_59 AC 73 ms
71,532 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
    
L.sort(key=lambda x:x[1])

LLIST=[[] for i in range(N+2)]

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

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

for i in range(N+2):
    DP[i]=DP[i-1]
    
    for x,z in LLIST[i]:
        if i==x and USE[i]==1:
            DP[i]=DP[i]+z
            
        elif i==x and USE[i]==0:
            if DP[i]<DP[i]+z-A:
                DP[i]=DP[i]+z-A
                USE[i]=1
            
        elif i==N+1 and USE[x]==1:
            if DP[i]<DP[x]+z:
                DP[i]=DP[x]+z

        elif i==N+1 and USE[x]==0:
            if DP[i]<DP[x]+z-A:
                DP[i]=DP[x]+z-A

        elif USE[x]==1:
            if DP[i]<DP[x]+z-A:
                DP[i]=DP[x]+z-A
                USE[i]=1
                
        elif USE[x]==0:
            if DP[i]<DP[x]+z-2*A:
                DP[i]=DP[x]+z-2*A
                USE[i]=1


print(DP[-1])


        
0