結果

問題 No.2712 Play more!
ユーザー sepa38sepa38
提出日時 2024-03-30 21:39:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 77,200 KB
最終ジャッジ日時 2024-03-30 21:39:40
合計ジャッジ時間 4,206 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,604 KB
testcase_01 AC 39 ms
55,604 KB
testcase_02 AC 39 ms
55,604 KB
testcase_03 AC 38 ms
55,604 KB
testcase_04 WA -
testcase_05 AC 39 ms
55,604 KB
testcase_06 AC 40 ms
55,604 KB
testcase_07 AC 75 ms
73,872 KB
testcase_08 AC 75 ms
74,512 KB
testcase_09 AC 76 ms
74,512 KB
testcase_10 WA -
testcase_11 AC 75 ms
73,988 KB
testcase_12 AC 82 ms
76,688 KB
testcase_13 AC 73 ms
73,092 KB
testcase_14 AC 71 ms
72,976 KB
testcase_15 AC 86 ms
77,072 KB
testcase_16 AC 72 ms
73,092 KB
testcase_17 AC 73 ms
72,840 KB
testcase_18 AC 67 ms
70,732 KB
testcase_19 AC 69 ms
72,876 KB
testcase_20 AC 81 ms
76,548 KB
testcase_21 AC 80 ms
76,548 KB
testcase_22 AC 82 ms
76,816 KB
testcase_23 AC 72 ms
73,860 KB
testcase_24 AC 71 ms
72,836 KB
testcase_25 AC 70 ms
73,092 KB
testcase_26 AC 69 ms
72,852 KB
testcase_27 AC 68 ms
72,976 KB
testcase_28 AC 59 ms
66,324 KB
testcase_29 AC 72 ms
72,964 KB
testcase_30 AC 74 ms
74,256 KB
testcase_31 AC 85 ms
77,200 KB
testcase_32 AC 86 ms
77,184 KB
testcase_33 AC 45 ms
57,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n, m = map(int, input().split())
a = list(map(int, input().split()))
e = [[] for _ in range(n)]
for _ in range(m):
  u, v, c = map(int, input().split())
  u -= 1
  v -= 1
  c = a[v] - c
  e[u].append([v, c])
inf = 1 << 60
sat = [-inf] * n
sat[0] = a[0]
d = deque([0])
while d:
  u = d.popleft()
  for v, c in e[u]:
    if sat[v] < sat[u] + c:
      if sat[v] == -inf:
        d.append(v)
      sat[v] = sat[u] + c
sat2 = sat[:]
for u in range(n):
  for v, c in e[u]:
    if sat2[v] < sat2[u] + c:
      print("inf")
      exit()
print(sat[-1])
0