結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-21 19:51:01 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 789 bytes |
| コンパイル時間 | 82 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-07-08 05:26:25 |
| 合計ジャッジ時間 | 2,269 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 3 |
| other | AC * 10 RE * 30 |
ソースコード
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]])
dp = [[10**9 for i in range(c+1)] for j in range(n+1)]
#dp[i][j] := i番目の街に行き、j円使った時の最短時間
dp[0][0] = 0
dp[1][0] = 0
for i in range(1,n+1):
for j in range(c+1):
if dp[i][j] != 10**9:
for next_node,cost, time in adjacent_list[i]:
dp[next_node][j+cost] = min(dp[next_node][j+cost], dp[i][j] + time)
ans = 10**9
for i in range(c+1):
ans = min(ans, dp[-1][i])
if ans == 10**9:
print(-1)
else:
print(ans)