結果

問題 No.2387 Yokan Factory
ユーザー miya145592miya145592
提出日時 2023-07-21 23:44:09
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 792 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 117,296 KB
最終ジャッジ日時 2023-10-21 23:43:46
合計ジャッジ時間 7,947 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,452 KB
testcase_01 AC 43 ms
53,304 KB
testcase_02 AC 42 ms
53,304 KB
testcase_03 AC 40 ms
53,304 KB
testcase_04 AC 40 ms
53,304 KB
testcase_05 AC 39 ms
53,304 KB
testcase_06 AC 39 ms
53,304 KB
testcase_07 AC 39 ms
53,304 KB
testcase_08 AC 40 ms
53,304 KB
testcase_09 AC 40 ms
53,304 KB
testcase_10 AC 40 ms
53,304 KB
testcase_11 AC 40 ms
53,304 KB
testcase_12 AC 40 ms
53,304 KB
testcase_13 AC 39 ms
53,304 KB
testcase_14 AC 40 ms
53,304 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop

INF = 10 ** 20

def dijkstra(s, N): # (始点, ノード数)
    dist = [-1 for _ in range(N)]
    hq = [(0, INF, s)]
    dist[s] = INF
    while hq:
        d, w, v = heappop(hq) # ノードを pop する
        for to, cost, width in G[v]: # ノード v に隣接しているノードに対して
            nw = min(w, width)
            nd = d+cost
            if nd>X:
                continue
            if dist[to] < nw :
                dist[to] = nw
                heappush(hq, (nd, nw, to))
    return dist

N, M, X = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    u-=1
    v-=1
    G[u].append((v, a, b))
    G[v].append((u, a, b))

ans = dijkstra(0, N)
print(ans[-1])
0