結果
問題 | No.1 道のショートカット |
ユーザー |
👑 |
提出日時 | 2022-06-12 15:28:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 64,000 KB |
最終ジャッジ日時 | 2024-09-23 03:52:33 |
合計ジャッジ時間 | 3,622 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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())) bef = [[] for _ in range(n)] for s, t, y, m in zip(S, T, Y, M): s -= 1 t -= 1 bef[t].append((s, y, m)) inf = 1 << 30 dp = [[inf] * (c + 1) for _ in range(n)] dp[0][0] = 0 for t in range(1, n): for s, y, m in bef[t]: for i in range(y, c + 1): dp[t][i] = min(dp[t][i], dp[s][i - y] + m) ans = min(dp[-1]) if ans == inf: print(-1) else: print(ans)