結果

問題 No.1 道のショートカット
ユーザー kjnhokjnho
提出日時 2017-03-22 22:45:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,229 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-07-08 04:51:28
合計ジャッジ時間 2,197 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,880 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 28 ms
10,880 KB
testcase_03 AC 27 ms
10,880 KB
testcase_04 AC 26 ms
10,752 KB
testcase_05 AC 25 ms
10,752 KB
testcase_06 AC 25 ms
10,752 KB
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 28 ms
11,008 KB
testcase_09 AC 26 ms
10,880 KB
testcase_10 AC 28 ms
10,880 KB
testcase_11 AC 28 ms
11,008 KB
testcase_12 AC 29 ms
11,008 KB
testcase_13 AC 29 ms
11,008 KB
testcase_14 AC 26 ms
10,752 KB
testcase_15 RE -
testcase_16 AC 26 ms
10,752 KB
testcase_17 RE -
testcase_18 AC 25 ms
10,880 KB
testcase_19 AC 25 ms
10,880 KB
testcase_20 AC 25 ms
10,880 KB
testcase_21 AC 25 ms
10,880 KB
testcase_22 AC 25 ms
10,752 KB
testcase_23 AC 29 ms
11,136 KB
testcase_24 AC 27 ms
11,008 KB
testcase_25 AC 25 ms
10,880 KB
testcase_26 AC 25 ms
10,880 KB
testcase_27 AC 28 ms
11,136 KB
testcase_28 RE -
testcase_29 AC 28 ms
11,008 KB
testcase_30 AC 25 ms
10,880 KB
testcase_31 AC 27 ms
11,008 KB
testcase_32 AC 27 ms
11,008 KB
testcase_33 AC 26 ms
10,752 KB
testcase_34 AC 28 ms
11,008 KB
testcase_35 AC 27 ms
11,136 KB
testcase_36 AC 27 ms
10,880 KB
testcase_37 AC 27 ms
10,880 KB
testcase_38 AC 26 ms
10,752 KB
testcase_39 AC 26 ms
10,752 KB
testcase_40 AC 25 ms
10,752 KB
testcase_41 AC 26 ms
10,752 KB
testcase_42 RE -
testcase_43 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush, heapify


def main():
    N = int(input())
    C = int(input())
    V = int(input())
    S = list(map(int, input().split()))
    T = list(map(int, input().split()))
    Y = list(map(int, input().split()))  # money
    M = list(map(int, input().split()))  # time

    MAP = [[] for v in range(V)]

    for v in range(V):
        MAP[S[v]-1].append((M[v], Y[v], T[v]-1))

    m_cost = 0
    t_cost = 0
    Q = [(0, 0, 0)]  # time_cost, money_cost, point
    tcosts = [float("inf")] * V  # time cost map
    mcosts = [float("inf")] * V  # time cost map
    R = [False] * N  # reached

    while len(Q) > 0:
        t_cost, m_cost, point = heappop(Q)
        if point == N-1:
            print(t_cost)
            return

        for n in MAP[point]:
            new_tcost = t_cost + n[0]
            new_mcost = m_cost + n[1]
            new_point = n[2]
            if m_cost + n[1] > C:
                continue
            if new_tcost < tcosts[new_point] or new_mcost < mcosts[new_point]:
                heappush(Q, (new_tcost, new_mcost, new_point))
                tcosts[point] = new_tcost
                mcosts[point] = new_mcost

    print(-1)


if __name__ == "__main__":
    main()
0