結果

問題 No.1 道のショートカット
ユーザー ikatakosikatakos
提出日時 2016-11-15 21:23:53
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 568 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 8,848 KB
最終ジャッジ日時 2023-09-27 22:02:12
合計ジャッジ時間 2,591 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,948 KB
testcase_01 AC 16 ms
8,164 KB
testcase_02 AC 16 ms
7,940 KB
testcase_03 AC 17 ms
8,036 KB
testcase_04 AC 16 ms
7,976 KB
testcase_05 AC 16 ms
8,044 KB
testcase_06 AC 17 ms
7,968 KB
testcase_07 AC 16 ms
8,108 KB
testcase_08 AC 18 ms
8,512 KB
testcase_09 AC 18 ms
8,276 KB
testcase_10 AC 18 ms
8,708 KB
testcase_11 AC 18 ms
8,760 KB
testcase_12 AC 20 ms
8,848 KB
testcase_13 AC 19 ms
8,824 KB
testcase_14 AC 17 ms
8,116 KB
testcase_15 AC 17 ms
8,108 KB
testcase_16 AC 18 ms
8,052 KB
testcase_17 AC 17 ms
8,056 KB
testcase_18 AC 17 ms
8,004 KB
testcase_19 AC 17 ms
8,156 KB
testcase_20 AC 17 ms
8,040 KB
testcase_21 AC 17 ms
8,112 KB
testcase_22 AC 17 ms
8,052 KB
testcase_23 AC 22 ms
8,688 KB
testcase_24 AC 19 ms
8,680 KB
testcase_25 AC 17 ms
8,152 KB
testcase_26 AC 17 ms
8,048 KB
testcase_27 AC 19 ms
8,716 KB
testcase_28 AC 16 ms
8,052 KB
testcase_29 AC 19 ms
8,576 KB
testcase_30 AC 17 ms
8,432 KB
testcase_31 AC 19 ms
8,564 KB
testcase_32 AC 19 ms
8,472 KB
testcase_33 AC 18 ms
8,640 KB
testcase_34 AC 19 ms
8,468 KB
testcase_35 AC 18 ms
8,544 KB
testcase_36 AC 19 ms
8,688 KB
testcase_37 AC 18 ms
8,480 KB
testcase_38 AC 17 ms
8,112 KB
testcase_39 AC 17 ms
7,980 KB
testcase_40 AC 17 ms
8,108 KB
testcase_41 AC 17 ms
7,980 KB
testcase_42 AC 16 ms
8,044 KB
testcase_43 AC 17 ms
8,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappush, heappop

n, c, v = map(int, (input() for _ in range(3)))
connections = [set() for _ in range(n + 1)]
for s, t, y, m in zip(*(map(int, input().split()) for _ in range(4))):
    connections[s].add((m, t, y))

queue = [(*con, c - con[2]) for con in connections[1] if con[2] <= c]
heapify(queue)
while queue:
    m, t, y, c = heappop(queue)
    if t == n:
        print(m)
        break
    for nm, nt, ny in connections[t]:
        if c < ny:
            continue
        heappush(queue, (m + nm, nt, ny, c - ny))
else:
    print(-1)
0