結果

問題 No.2739 Time is money
ユーザー tkykwtnbtkykwtnb
提出日時 2024-04-20 14:03:35
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 622 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 82,984 KB
実行使用メモリ 308,016 KB
最終ジャッジ日時 2024-04-20 14:04:03
合計ジャッジ時間 5,430 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
62,140 KB
testcase_01 AC 38 ms
55,852 KB
testcase_02 AC 478 ms
163,032 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0