結果
| 問題 | 
                            No.1 道のショートカット
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-05-21 19:51:57 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 134 ms / 5,000 ms | 
| コード長 | 827 bytes | 
| コンパイル時間 | 134 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 11,392 KB | 
| 最終ジャッジ日時 | 2024-07-20 16:48:18 | 
| 合計ジャッジ時間 | 3,264 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 40 | 
ソースコード
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]:
                if j + cost <= c:
                    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)