結果
問題 |
No.2739 Time is money
|
ユーザー |
|
提出日時 | 2025-07-13 12:48:10 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 828 bytes |
コンパイル時間 | 226 ms |
コンパイル使用メモリ | 82,524 KB |
実行使用メモリ | 164,040 KB |
最終ジャッジ日時 | 2025-07-13 12:48:29 |
合計ジャッジ時間 | 17,573 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 WA * 1 |
ソースコード
import heapq N,M,X = map(int,input().split()) G = {i:[] for i in range(1,N+1)} for _ in range(M): u,v,c,t = map(int,input().split()) G[u].append((v,c,t)) G[v].append((u,c,t)) INFTY = 10**12 dist = [INFTY]*(N+1) visit = [0]*(N+1) que = [(0,1,0)] dist[1] = 0 while que: t,v,c = heapq.heappop(que) if t>dist[v]:continue visit[v] = 1 for u,dc,dt in G[v]: if visit[u]==1:continue if c>=dc: nc = c-dc nt = t+dt if nt<dist[u]: dist[u] = nt heapq.heappush(que,(nt,u,nc)) else: k = (dc-c+X-1)//X nc = c+k*X-dc nt = t+dt+k if nt<dist[u]: dist[u] = nt heapq.heappush(que,(nt,u,nc)) if dist[N]==INFTY: print(-1) else: print(dist[N])