結果
問題 |
No.2712 Play more!
|
ユーザー |
👑 |
提出日時 | 2024-03-31 15:31:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 730 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 82,788 KB |
実行使用メモリ | 77,876 KB |
最終ジャッジ日時 | 2024-09-30 20:49:39 |
合計ジャッジ時間 | 3,971 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 RE * 1 |
other | AC * 24 WA * 8 RE * 1 |
ソースコード
import heapq def solve(n, m, a, uvw): graph = [[] for _ in range(n)] for ui, vi, wi in uvw: graph[ui-1].append((vi - 1, wi)) pq = [(-a[0], 0)] mn = [10 ** 18] * n mn[0] = -a[0] while True: cost, node = heapq.heappop(pq) if node == n - 1: return -cost if mn[node] < cost: continue if cost < mn[node]: return "inf" for next_node, next_cost in graph[node]: if a[next_node] <= -cost - next_cost: continue a[next_node] = -cost + next_cost heapq.heappush(pq, (-a[next_node], next_node)) n, m = [int(x) for x in input().split()] a = [int(x) for x in input().split()] uvw = [[int(x) for x in input().split()] for _ in range(m)] print(solve(n, m, a, uvw))