結果
問題 |
No.2712 Play more!
|
ユーザー |
![]() |
提出日時 | 2024-03-31 14:26:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 982 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 82,120 KB |
実行使用メモリ | 78,100 KB |
最終ジャッジ日時 | 2024-09-30 19:32:22 |
合計ジャッジ時間 | 3,399 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 20 |
ソースコード
# oj t -c "python3 main.py" import sys,math from collections import defaultdict,deque from itertools import combinations,permutations,accumulate,product from bisect import bisect,bisect_left,bisect_right from heapq import heappop,heappush,heapify #from sortedcontainers import SortedList,SortedSet def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def ms(): return map(int, input().split()) def li(): return list(map(int,input().split())) inf = pow(10,18) #//////////////////////////////////// N,M = ms() A = [-1]+li() G = [set() for _ in range(N+1)] for _ in range(M): u,v,c = ms() G[u].add((v,c)) H = [] heappush(H,(-A[1],1)) visited = [False]*(N+1) while H: c,v = heappop(H) if visited[v]: continue c *= -1 if v==N: print(c) exit() visited[v] = True for v2,c2 in G[v]: if A[v2]<c2: continue if A[v2]>c2 and visited[v2]: print('inf') exit() if visited[v2]: continue heappush(H,(-(c+A[v2]-c2),v2))