結果

問題 No.2712 Play more!
ユーザー sasa8uyauyasasa8uyauya
提出日時 2024-04-05 14:46:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,688 KB
最終ジャッジ日時 2024-04-05 14:46:49
合計ジャッジ時間 7,271 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 315 ms
77,456 KB
testcase_08 AC 307 ms
77,688 KB
testcase_09 AC 291 ms
77,584 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 166 ms
76,552 KB
testcase_12 WA -
testcase_13 AC 158 ms
76,184 KB
testcase_14 AC 194 ms
76,572 KB
testcase_15 WA -
testcase_16 AC 123 ms
76,432 KB
testcase_17 AC 74 ms
74,136 KB
testcase_18 AC 108 ms
76,192 KB
testcase_19 AC 95 ms
76,060 KB
testcase_20 AC 200 ms
76,692 KB
testcase_21 AC 126 ms
76,652 KB
testcase_22 AC 286 ms
76,940 KB
testcase_23 AC 91 ms
76,396 KB
testcase_24 AC 134 ms
76,316 KB
testcase_25 AC 89 ms
76,300 KB
testcase_26 AC 113 ms
76,060 KB
testcase_27 AC 215 ms
76,196 KB
testcase_28 AC 101 ms
75,572 KB
testcase_29 AC 134 ms
76,440 KB
testcase_30 AC 297 ms
76,696 KB
testcase_31 AC 491 ms
74,620 KB
testcase_32 AC 282 ms
73,596 KB
testcase_33 AC 46 ms
61,548 KB
testcase_34 AC 37 ms
53,460 KB
testcase_35 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
a=list(map(int,input().split()))
e=[]
for i in range(m):
  x,y,z=map(int,input().split())
  x-=1
  y-=1
  e+=[(x,y,z-a[x])]
X=10**20
v=[X]*n
v[0]=0
for i in range(n):
  f=0
  for x,y,z in e:
    if v[y]>v[x]+z:
      v[y]=v[x]+z
      f=1
      p=y
if f==0:
  print(-v[-1]+a[-1])
else:
  E=[[] for i in range(n)]
  for x,y,z in e:
    E[x]+=[y]
  q=[p]
  u=[0]*n
  u[p]=1
  for s in q:
    for t in E[s]:
      if u[t]==0:
        u[t]=1
        q+=[t]
  print(-v[-1]+a[-1] if u[-1]==0 else "inf")
0