結果

問題 No.1 道のショートカット
ユーザー rpy3cpprpy3cpp
提出日時 2015-03-25 22:41:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,198 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 8,592 KB
最終ジャッジ日時 2023-09-22 12:02:05
合計ジャッジ時間 2,560 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,324 KB
testcase_01 AC 16 ms
8,356 KB
testcase_02 AC 16 ms
8,364 KB
testcase_03 AC 16 ms
8,336 KB
testcase_04 AC 16 ms
8,276 KB
testcase_05 AC 17 ms
8,376 KB
testcase_06 AC 17 ms
8,340 KB
testcase_07 AC 17 ms
8,460 KB
testcase_08 AC 19 ms
8,152 KB
testcase_09 AC 18 ms
8,156 KB
testcase_10 AC 17 ms
8,188 KB
testcase_11 AC 18 ms
8,164 KB
testcase_12 AC 18 ms
8,592 KB
testcase_13 AC 18 ms
8,584 KB
testcase_14 WA -
testcase_15 AC 16 ms
8,300 KB
testcase_16 WA -
testcase_17 AC 16 ms
8,376 KB
testcase_18 AC 17 ms
8,156 KB
testcase_19 AC 17 ms
8,124 KB
testcase_20 AC 17 ms
8,156 KB
testcase_21 AC 17 ms
8,084 KB
testcase_22 AC 17 ms
8,220 KB
testcase_23 AC 18 ms
8,164 KB
testcase_24 AC 18 ms
8,252 KB
testcase_25 AC 16 ms
8,112 KB
testcase_26 AC 17 ms
8,124 KB
testcase_27 AC 18 ms
8,116 KB
testcase_28 AC 16 ms
8,328 KB
testcase_29 WA -
testcase_30 AC 17 ms
8,128 KB
testcase_31 AC 17 ms
8,152 KB
testcase_32 WA -
testcase_33 AC 17 ms
8,100 KB
testcase_34 WA -
testcase_35 AC 18 ms
8,124 KB
testcase_36 WA -
testcase_37 AC 17 ms
8,124 KB
testcase_38 AC 16 ms
8,312 KB
testcase_39 AC 17 ms
8,080 KB
testcase_40 AC 17 ms
8,124 KB
testcase_41 AC 17 ms
8,160 KB
testcase_42 AC 17 ms
8,360 KB
testcase_43 AC 17 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

def read_data():
    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()))
    M = list(map(int, input().split()))
    return N, C, V, S, T, Y, M

def solve(N, C, V, S, T, Y, M):
    Es = init_Es(N, S, T, Y, M)
    hq = []
    pos = 1
    time = 0
    cost = 0
    status = (time, cost, pos)
    heapq.heappush(hq, status)
    t = [float('inf') for i in range(N + 1)]
    while hq:
        time, cost, pos = heapq.heappop(hq)
        if pos == N:
            return time
        for new_pos, dif_cost, dif_time in Es[pos]:
            new_cost = cost + dif_cost
            new_time = time + dif_time
            if t[new_pos] > new_time and new_cost <= C:
                t[new_pos] = new_time
                status = (new_time, new_cost, new_pos)
                heapq.heappush(hq, status)
    return -1

def init_Es(N, S, T, Y, M):
    Es = [[] for i in range(N+1)]
    for s, t, y, m in zip(S, T, Y, M):
        Es[s].append((t, y, m))
    return Es


if __name__ == '__main__':
    N, C, V, S, T, Y, M = read_data()
    print(solve(N, C, V, S, T, Y, M))
0