結果
問題 |
No.2739 Time is money
|
ユーザー |
|
提出日時 | 2024-04-20 14:03:35 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 622 bytes |
コンパイル時間 | 431 ms |
コンパイル使用メモリ | 82,316 KB |
実行使用メモリ | 308,068 KB |
最終ジャッジ日時 | 2024-10-12 09:35:58 |
合計ジャッジ時間 | 5,851 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 TLE * 1 -- * 16 |
ソースコード
from collections import deque,defaultdict N,M,X=map(int,input().split()) G=[[] for _ in range(N)] C=defaultdict(int) T=defaultdict(int) for _ in range(M): u,v,c,t=map(int,input().split()) u-=1;v-=1 G[u].append(v) G[v].append(u) C[(u,v)]=c C[(v,u)]=c T[(u,v)]=t T[(v,u)]=t vis=[(-1,-1) for _ in range(N)] Q=deque() Q.append((0,0,0)) while Q: now,c,t=Q.popleft() vis[now]=(c,t) for nxt in G[now]: if vis[nxt]==(-1,-1) or t+T[(now,nxt)]<vis[nxt][1]: Q.append((nxt,c+C[(now,nxt)],t+T[(now,nxt)])) ans=(vis[N-1][0]+X-1)//X+vis[N-1][1] print(ans if ans>0 else -1)