結果

問題 No.1 道のショートカット
ユーザー sotanishysotanishy
提出日時 2021-03-16 19:37:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 5,000 ms
コード長 815 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,528 KB
実行使用メモリ 77,700 KB
最終ジャッジ日時 2024-04-25 21:25:20
合計ジャッジ時間 4,378 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,104 KB
testcase_01 AC 37 ms
54,752 KB
testcase_02 AC 36 ms
53,016 KB
testcase_03 AC 37 ms
53,184 KB
testcase_04 AC 38 ms
54,324 KB
testcase_05 AC 36 ms
53,228 KB
testcase_06 AC 36 ms
53,164 KB
testcase_07 AC 37 ms
53,260 KB
testcase_08 AC 83 ms
77,184 KB
testcase_09 AC 56 ms
69,296 KB
testcase_10 AC 78 ms
76,740 KB
testcase_11 AC 97 ms
77,000 KB
testcase_12 AC 110 ms
77,200 KB
testcase_13 AC 112 ms
77,700 KB
testcase_14 AC 37 ms
53,436 KB
testcase_15 AC 37 ms
52,748 KB
testcase_16 AC 50 ms
63,916 KB
testcase_17 AC 37 ms
54,060 KB
testcase_18 AC 37 ms
54,444 KB
testcase_19 AC 38 ms
54,532 KB
testcase_20 AC 80 ms
76,504 KB
testcase_21 AC 50 ms
63,868 KB
testcase_22 AC 38 ms
54,948 KB
testcase_23 AC 101 ms
77,112 KB
testcase_24 AC 106 ms
77,308 KB
testcase_25 AC 84 ms
76,488 KB
testcase_26 AC 70 ms
72,372 KB
testcase_27 AC 120 ms
77,260 KB
testcase_28 AC 37 ms
53,684 KB
testcase_29 AC 73 ms
74,392 KB
testcase_30 AC 45 ms
63,548 KB
testcase_31 AC 51 ms
64,748 KB
testcase_32 AC 81 ms
77,004 KB
testcase_33 AC 72 ms
74,628 KB
testcase_34 AC 103 ms
77,100 KB
testcase_35 AC 42 ms
60,788 KB
testcase_36 AC 62 ms
70,192 KB
testcase_37 AC 45 ms
62,956 KB
testcase_38 AC 36 ms
54,440 KB
testcase_39 AC 36 ms
53,556 KB
testcase_40 AC 42 ms
59,800 KB
testcase_41 AC 36 ms
53,204 KB
testcase_42 AC 36 ms
53,788 KB
testcase_43 AC 38 ms
54,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N = int(input())
C = int(input())
V = int(input())
S = list(map(lambda x: int(x) - 1, input().split()))
T = list(map(lambda x: int(x) - 1, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))

G = [[] for _ in range(N)]
for s, t, y, m in zip(S, T, Y, M):
    G[s].append((t, y, m))

INF = 10**18
dist = [[INF] * (C + 1) for _ in range(N)]
dist[0][0] = 0
pq = [(0, 0, 0)]
while pq:
    d, s, c = heappop(pq)
    if dist[s][c] < d:
        continue
    for t, y, m in G[s]:
        if c + y > C:
            continue
        nd = d + m
        nc = c + y
        if nd < dist[t][nc]:
            dist[t][nc] = nd
            heappush(pq, (nd, t, nc))
ans = min(dist[-1])
print(ans if ans < INF else -1)


0