結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-21 19:31:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 609 bytes |
| コンパイル時間 | 244 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 16,128 KB |
| 最終ジャッジ日時 | 2024-07-08 05:26:22 |
| 合計ジャッジ時間 | 6,896 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 TLE * 1 -- * 32 |
ソースコード
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()))
adjacent_list = [[] for i in range(n+1)]
for i in range(v):
adjacent_list[s[i]].append([t[i],y[i],m[i]])
ans = 10**9
def dfs(node,cost,time):
if node == n:
global ans
ans = min(ans, time)
for n_node, n_cost, n_time in adjacent_list[node]:
if n_cost + cost <= c:
dfs(n_node,n_cost + cost, time + n_time)
dfs(1,0,0)
if ans == 10**9:
print(-1)
else:
print(ans)