結果

問題 No.1 道のショートカット
ユーザー tookunn_1213tookunn_1213
提出日時 2016-08-23 01:20:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 720 ms / 5,000 ms
コード長 672 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 15,524 KB
最終ジャッジ日時 2023-09-27 21:58:13
合計ジャッジ時間 5,852 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,124 KB
testcase_01 AC 14 ms
8,048 KB
testcase_02 AC 15 ms
8,092 KB
testcase_03 AC 15 ms
8,044 KB
testcase_04 AC 14 ms
8,184 KB
testcase_05 AC 14 ms
8,232 KB
testcase_06 AC 14 ms
8,220 KB
testcase_07 AC 14 ms
8,068 KB
testcase_08 AC 176 ms
9,592 KB
testcase_09 AC 38 ms
8,648 KB
testcase_10 AC 109 ms
9,224 KB
testcase_11 AC 198 ms
10,320 KB
testcase_12 AC 720 ms
14,856 KB
testcase_13 AC 676 ms
14,584 KB
testcase_14 AC 15 ms
8,016 KB
testcase_15 AC 14 ms
8,084 KB
testcase_16 AC 18 ms
8,236 KB
testcase_17 AC 14 ms
8,044 KB
testcase_18 AC 15 ms
8,088 KB
testcase_19 AC 15 ms
8,020 KB
testcase_20 AC 35 ms
8,496 KB
testcase_21 AC 17 ms
8,060 KB
testcase_22 AC 15 ms
8,088 KB
testcase_23 AC 334 ms
13,688 KB
testcase_24 AC 300 ms
12,220 KB
testcase_25 AC 50 ms
8,572 KB
testcase_26 AC 30 ms
8,220 KB
testcase_27 AC 376 ms
11,428 KB
testcase_28 AC 15 ms
8,132 KB
testcase_29 AC 85 ms
9,328 KB
testcase_30 AC 21 ms
8,080 KB
testcase_31 AC 52 ms
9,852 KB
testcase_32 AC 160 ms
9,932 KB
testcase_33 AC 71 ms
8,992 KB
testcase_34 AC 454 ms
15,524 KB
testcase_35 AC 18 ms
8,080 KB
testcase_36 AC 49 ms
8,772 KB
testcase_37 AC 24 ms
8,636 KB
testcase_38 AC 15 ms
8,016 KB
testcase_39 AC 14 ms
8,164 KB
testcase_40 AC 18 ms
8,100 KB
testcase_41 AC 15 ms
8,016 KB
testcase_42 AC 14 ms
8,088 KB
testcase_43 AC 14 ms
8,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N,C,V = int(input()),int(input()),int(input())
S = [int(i) - 1 for i in input().split()]
T = [int(i) - 1 for i in input().split()]
Y = [int(i) for i in input().split()]
M = [int(i) for i in input().split()]
used = [[False for j in range(N)]for i in range(300 + 1)]
def dijkstra(s,t):
	q = [(0,0,s)]
	ret = 10 ** 9 + 7
	while len(q) > 0:
		d = heapq.heappop(q)
		if d[1] > C:
			continue
		if used[d[1]][d[2]]:
			continue
		used[d[1]][d[2]] = True
		if d[2] == t:
			ret = min(ret,d[0])
			continue
		for i in range(V):
			if S[i] == d[2]:
				heapq.heappush(q,(d[0] + M[i],d[1] + Y[i],T[i]))
	return -1 if ret == 10 ** 9 + 7 else ret
print(dijkstra(0,N - 1))
0