結果
問題 | No.1 道のショートカット |
ユーザー |
|
提出日時 | 2021-07-09 11:06:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 202 ms / 5,000 ms |
コード長 | 631 bytes |
コンパイル時間 | 89 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-07-01 13:56:16 |
合計ジャッジ時間 | 4,205 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 40 |
ソースコード
N = int(input()) C = int(input()) V = int(input()) S = list(map(lambda x: int(x)-1, input().split())) T = list(map(lambda x: int(x)-1, input().split())) Y = list(map(int, input().split())) M = list(map(int, input().split())) INF = 10**10 edge = [[] for _ in range(N)] for s, t, y, m in zip(S, T, Y, M): edge[s].append([t, y, m]) dp = [[INF]*(C+10) for _ in range(N+10)] dp[0][0] = 0 for i in range(N-1): for t, y, m in edge[i]: for j in range(C+1): if j+y > C: break dp[t][j+y] = min(dp[t][j+y], dp[i][j]+m) if min(dp[N-1])==INF: print(-1) else: print(min(dp[N-1]))