結果
問題 | No.2712 Play more! |
ユーザー | 👑 timi |
提出日時 | 2024-04-06 12:52:16 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 903 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 78,092 KB |
最終ジャッジ日時 | 2024-04-06 12:52:24 |
合計ジャッジ時間 | 7,662 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
55,616 KB |
testcase_01 | AC | 41 ms
55,616 KB |
testcase_02 | AC | 41 ms
55,616 KB |
testcase_03 | AC | 41 ms
55,616 KB |
testcase_04 | AC | 40 ms
55,616 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 231 ms
77,320 KB |
testcase_10 | AC | 41 ms
55,616 KB |
testcase_11 | AC | 206 ms
77,180 KB |
testcase_12 | AC | 361 ms
77,452 KB |
testcase_13 | AC | 205 ms
77,180 KB |
testcase_14 | WA | - |
testcase_15 | AC | 653 ms
78,092 KB |
testcase_16 | AC | 149 ms
77,312 KB |
testcase_17 | AC | 95 ms
76,932 KB |
testcase_18 | AC | 134 ms
76,688 KB |
testcase_19 | AC | 118 ms
76,956 KB |
testcase_20 | AC | 261 ms
77,304 KB |
testcase_21 | AC | 184 ms
77,808 KB |
testcase_22 | AC | 339 ms
77,580 KB |
testcase_23 | AC | 106 ms
77,168 KB |
testcase_24 | AC | 165 ms
77,060 KB |
testcase_25 | AC | 94 ms
77,300 KB |
testcase_26 | AC | 159 ms
76,820 KB |
testcase_27 | WA | - |
testcase_28 | AC | 102 ms
68,284 KB |
testcase_29 | AC | 171 ms
77,188 KB |
testcase_30 | AC | 343 ms
77,452 KB |
testcase_31 | AC | 277 ms
77,324 KB |
testcase_32 | AC | 233 ms
77,204 KB |
testcase_33 | AC | 50 ms
61,244 KB |
testcase_34 | AC | 41 ms
55,616 KB |
testcase_35 | AC | 41 ms
55,612 KB |
ソースコード
N,M=map(int,input().split()) A=list(map(int, input().split())) n=N def bellman_ford(s): d = [float('inf')]*n # 各頂点への最小コスト d[s] = 0 # 自身への距離は0 for i in range(n): for x, y, z in g: if d[y] > d[x] + z and d[x]!=float('inf'): d[y] = d[x] + z if i == n-1 and y==n-1: return -1 return d g=[] D=[[]for _ in range(N)];C=[] for _ in range(M): x,y,z=map(int,input().split()) x-=1;y-=1 C.append((x,y,z)) D[y].append(x) #g.append([x, y, -z]) from collections import deque d=deque() V=[-1]*N V[N-1]=1 d.append(N-1) while d: now=d.popleft() for nex in D[now]: if V[nex]==-1: V[nex]=1 d.append(nex) for x,y,z in C: if V[x]+V[y]==2: g.append((x,y,-A[y]+z)) #print(V,g) ans=bellman_ford(0) #print(ans) if ans==-1: print('inf') else: print(A[0]-ans[-1])