結果

問題 No.2712 Play more!
ユーザー sasa8uyauyasasa8uyauya
提出日時 2024-04-05 14:48:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 588 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,972 KB
最終ジャッジ日時 2024-04-05 14:48:30
合計ジャッジ時間 7,561 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 36 ms
53,456 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 351 ms
78,716 KB
testcase_08 AC 374 ms
78,840 KB
testcase_09 AC 346 ms
78,588 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 228 ms
76,936 KB
testcase_12 AC 343 ms
77,584 KB
testcase_13 AC 181 ms
76,680 KB
testcase_14 AC 224 ms
77,072 KB
testcase_15 AC 588 ms
78,972 KB
testcase_16 AC 123 ms
76,816 KB
testcase_17 AC 90 ms
76,440 KB
testcase_18 AC 124 ms
76,460 KB
testcase_19 AC 103 ms
76,460 KB
testcase_20 AC 221 ms
77,060 KB
testcase_21 AC 146 ms
77,040 KB
testcase_22 AC 415 ms
77,568 KB
testcase_23 AC 103 ms
76,784 KB
testcase_24 AC 160 ms
76,696 KB
testcase_25 AC 91 ms
76,676 KB
testcase_26 AC 139 ms
76,576 KB
testcase_27 AC 243 ms
76,456 KB
testcase_28 AC 118 ms
75,828 KB
testcase_29 AC 150 ms
76,692 KB
testcase_30 AC 392 ms
77,584 KB
testcase_31 AC 167 ms
76,796 KB
testcase_32 AC 220 ms
74,364 KB
testcase_33 AC 45 ms
61,548 KB
testcase_34 AC 36 ms
53,460 KB
testcase_35 AC 36 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):
  p=[]
  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=[]
  u=[0]*n
  for s in p:
    q+=[s]
    v[s]=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