結果

問題 No.1 道のショートカット
ユーザー hiro1729hiro1729
提出日時 2023-07-27 09:05:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 698 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 66,764 KB
最終ジャッジ日時 2024-04-14 21:48:43
合計ジャッジ時間 3,237 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,868 KB
testcase_01 AC 42 ms
53,396 KB
testcase_02 AC 38 ms
53,256 KB
testcase_03 AC 38 ms
54,028 KB
testcase_04 AC 38 ms
53,020 KB
testcase_05 AC 38 ms
53,724 KB
testcase_06 AC 39 ms
53,484 KB
testcase_07 AC 38 ms
53,128 KB
testcase_08 AC 44 ms
61,208 KB
testcase_09 AC 41 ms
59,540 KB
testcase_10 AC 43 ms
59,808 KB
testcase_11 AC 44 ms
60,704 KB
testcase_12 AC 45 ms
61,664 KB
testcase_13 AC 45 ms
62,760 KB
testcase_14 AC 38 ms
53,572 KB
testcase_15 AC 38 ms
53,420 KB
testcase_16 AC 43 ms
59,356 KB
testcase_17 AC 39 ms
52,916 KB
testcase_18 AC 39 ms
54,248 KB
testcase_19 AC 38 ms
53,076 KB
testcase_20 AC 41 ms
58,688 KB
testcase_21 AC 37 ms
53,064 KB
testcase_22 AC 39 ms
54,316 KB
testcase_23 AC 58 ms
66,764 KB
testcase_24 AC 45 ms
60,920 KB
testcase_25 AC 41 ms
59,140 KB
testcase_26 AC 39 ms
54,168 KB
testcase_27 AC 47 ms
61,732 KB
testcase_28 AC 38 ms
54,644 KB
testcase_29 AC 44 ms
62,464 KB
testcase_30 AC 42 ms
59,672 KB
testcase_31 AC 44 ms
60,484 KB
testcase_32 AC 43 ms
60,776 KB
testcase_33 AC 43 ms
60,416 KB
testcase_34 AC 46 ms
61,788 KB
testcase_35 AC 47 ms
61,732 KB
testcase_36 AC 43 ms
59,968 KB
testcase_37 AC 42 ms
60,036 KB
testcase_38 AC 40 ms
54,960 KB
testcase_39 AC 39 ms
53,620 KB
testcase_40 AC 42 ms
59,972 KB
testcase_41 AC 39 ms
53,548 KB
testcase_42 AC 38 ms
53,108 KB
testcase_43 AC 38 ms
53,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush
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()))
	m = list(map(int, input().split()))
	x = [[] for _ in range(n)]
	for i in range(v):
		x[s[i] - 1].append((m[i], y[i], t[i] - 1))
	q = [(0, 0, 0)]
	tcs = [float("inf")] * n
	mcs = [float("inf")] * n
	while q:
		tc, mc, p = heappop(q)
		if p == n - 1:
			exit(print(tc))
		for i in x[p]:
			nt = tc + i[0]
			nm = mc + i[1]
			np = i[2]
			if mc + i[1] > c:
				continue
			if nt < tcs[np] or nm < mcs[np]:
				heappush(q, (nt, nm, np))
				tcs[p] = nt
				mcs[p] = nm
	print(-1)
main()
0