結果
問題 | No.2739 Time is money |
ユーザー | tkykwtnb |
提出日時 | 2024-04-21 13:31:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 908 bytes |
コンパイル時間 | 335 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 272,780 KB |
最終ジャッジ日時 | 2024-04-21 13:32:18 |
合計ジャッジ時間 | 16,777 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
59,520 KB |
testcase_01 | AC | 43 ms
54,144 KB |
testcase_02 | AC | 486 ms
162,988 KB |
testcase_03 | AC | 1,231 ms
222,548 KB |
testcase_04 | AC | 476 ms
162,852 KB |
testcase_05 | WA | - |
testcase_06 | TLE | - |
testcase_07 | AC | 1,899 ms
271,240 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 794 ms
237,888 KB |
testcase_11 | TLE | - |
testcase_12 | AC | 1,119 ms
264,348 KB |
testcase_13 | AC | 1,140 ms
264,468 KB |
testcase_14 | AC | 1,042 ms
241,496 KB |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
from collections import deque,defaultdict import heapq 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<<60,1<<60,1<<60) for _ in range(N)] # t,c,m attr=defaultdict(tuple) hq=[] heapq.heapify(hq) hq.append((0,0,0,0)) # t,c,m,nxt while hq: t,c,m,now=heapq.heappop(hq) vis[now]=(t,c,m) if now==N-1:break for nxt in G[now]: work=0 if c+C[(now,nxt)]>m: work=(m-c+C[(now,nxt)]+X-1)//X if t+T[(now,nxt)]+work<vis[nxt][0] or \ t+T[(now,nxt)]+work==vis[nxt][0] and c+C[(now,nxt)]<vis[nxt][1]: heapq.heappush(hq,((t+T[(now,nxt)]+work,c+C[(now,nxt)],m+X*work,nxt))) if vis[N-1][0]==1<<60:print(-1) else:print(vis[N-1][0])