結果
| 問題 | No.2739 Time is money | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-07-13 13:30:36 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 886 bytes | 
| コンパイル時間 | 276 ms | 
| コンパイル使用メモリ | 82,452 KB | 
| 実行使用メモリ | 210,684 KB | 
| 最終ジャッジ日時 | 2025-07-13 13:30:44 | 
| 合計ジャッジ時間 | 5,222 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 1 TLE * 1 -- * 16 | 
ソースコード
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
ans = INFTY
high = INFTY
low = 0
while high-low>1:
    mid = (high+low)//2
    dist = [INFTY]*(N+1)
    visit = [0]*(N+1)
    k = (mid+X-1)//X
    que = [(k,1,k*X)]
    dist[1] = k
    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))
    if dist[N]<INFTY:
        high = mid
        ans = min(ans,dist[N])
    else:
        low = mid
if ans==INFTY:
    print(-1)
else:
    print(ans)
            
            
            
        