結果

問題 No.1 道のショートカット
ユーザー snnekosnneko
提出日時 2019-03-18 00:10:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 986 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 8,420 KB
最終ジャッジ日時 2023-09-27 22:18:10
合計ジャッジ時間 3,146 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,796 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 16 ms
7,884 KB
testcase_03 AC 16 ms
7,880 KB
testcase_04 AC 16 ms
7,764 KB
testcase_05 AC 16 ms
7,976 KB
testcase_06 AC 16 ms
7,764 KB
testcase_07 AC 17 ms
7,844 KB
testcase_08 AC 26 ms
8,228 KB
testcase_09 AC 22 ms
8,216 KB
testcase_10 AC 26 ms
8,296 KB
testcase_11 AC 30 ms
8,348 KB
testcase_12 AC 36 ms
8,304 KB
testcase_13 AC 32 ms
8,420 KB
testcase_14 AC 17 ms
8,348 KB
testcase_15 AC 16 ms
7,824 KB
testcase_16 AC 19 ms
8,228 KB
testcase_17 AC 16 ms
7,824 KB
testcase_18 AC 17 ms
8,268 KB
testcase_19 AC 16 ms
8,252 KB
testcase_20 AC 19 ms
8,292 KB
testcase_21 AC 17 ms
8,280 KB
testcase_22 AC 17 ms
8,340 KB
testcase_23 AC 40 ms
8,364 KB
testcase_24 AC 33 ms
8,316 KB
testcase_25 AC 19 ms
8,208 KB
testcase_26 AC 18 ms
8,336 KB
testcase_27 AC 38 ms
8,416 KB
testcase_28 AC 16 ms
7,852 KB
testcase_29 AC 33 ms
8,220 KB
testcase_30 AC 18 ms
8,272 KB
testcase_31 AC 30 ms
8,360 KB
testcase_32 AC 24 ms
8,204 KB
testcase_33 AC 22 ms
8,296 KB
testcase_34 AC 30 ms
8,236 KB
testcase_35 AC 22 ms
8,296 KB
testcase_36 AC 24 ms
8,288 KB
testcase_37 AC 23 ms
8,232 KB
testcase_38 AC 17 ms
8,208 KB
testcase_39 AC 17 ms
8,296 KB
testcase_40 AC 19 ms
8,228 KB
testcase_41 AC 17 ms
8,208 KB
testcase_42 AC 16 ms
7,968 KB
testcase_43 AC 17 ms
7,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()))

town = [[(None, None)] for i in range(N)]
town[0] = [(0, 0)]
for i in range(N):
    for v in range(V):
        if S[v]-1 == i:
            for t in town[i]:
                if t[0] is None: continue
                cost = t[0] + Y[v]
                if cost > C: continue
                time = t[1] + M[v]
                if town[T[v]-1][0] == (None, None):
                    town[T[v]-1][0] = (cost, time)
                else:
                    for t1 in town[T[v]-1]:
                        if cost > t1[0] and time > t1[1]:
                            break
                    else:
                        town[T[v]-1].append((cost, time))

ans = 1000 * N
if town[N-1][0] == (None, None):
    ans = -1
else:
    for t in town[N-1]:
        if ans > t[1]: ans = t[1]

print(ans)
0