結果

問題 No.2712 Play more!
ユーザー prd_xxxprd_xxx
提出日時 2024-03-31 14:51:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 401 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,660 KB
最終ジャッジ日時 2024-03-31 14:51:38
合計ジャッジ時間 5,479 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 WA -
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 242 ms
74,228 KB
testcase_08 AC 200 ms
76,660 KB
testcase_09 AC 237 ms
74,228 KB
testcase_10 WA -
testcase_11 AC 177 ms
73,732 KB
testcase_12 AC 194 ms
74,356 KB
testcase_13 AC 135 ms
73,608 KB
testcase_14 AC 156 ms
73,112 KB
testcase_15 AC 262 ms
76,660 KB
testcase_16 AC 113 ms
74,220 KB
testcase_17 AC 79 ms
73,228 KB
testcase_18 AC 95 ms
72,876 KB
testcase_19 AC 81 ms
72,876 KB
testcase_20 AC 161 ms
76,140 KB
testcase_21 AC 119 ms
76,524 KB
testcase_22 AC 190 ms
76,404 KB
testcase_23 AC 90 ms
76,396 KB
testcase_24 AC 114 ms
72,968 KB
testcase_25 AC 81 ms
74,476 KB
testcase_26 AC 100 ms
72,868 KB
testcase_27 AC 140 ms
73,000 KB
testcase_28 AC 85 ms
66,344 KB
testcase_29 AC 117 ms
73,356 KB
testcase_30 AC 242 ms
74,356 KB
testcase_31 AC 197 ms
76,660 KB
testcase_32 AC 166 ms
76,532 KB
testcase_33 AC 47 ms
61,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
A = list(map(int,input().split()))
ABC = [tuple(map(int,input().split())) for _ in range(M)]

INF = 10**18
dist = [INF] * N
dist[0] = -A[0]
for i in range(N):
    for a,b,c in ABC:
        a,b = a-1,b-1
        dd = c - A[b]
        if dist[b] > dist[a] + dd:
            dist[b] = dist[a] + dd
            if i==N-1:
                exit(print('inf'))

print(-dist[-1])
0