题库练习 April Fools' Problem (medium)
← 上一题 下一题 →

A10882 | April Fools' Problem (medium)

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

The marmots need to prepare $k$ problems for HC $^{2}$ over $n$ days. Each problem, once prepared, also has to be printed.

The preparation of a problem on day $i$ (at most one per day) costs $a_{i}$ CHF, and the printing of a problem on day $i$ (also at most one per day) costs $b_{i}$ CHF. Of course, a problem cannot be printed before it has been prepared (but doing both on the same day is fine).

What is the minimum cost of preparation and printing?

输入格式

The first line of input contains two space-separated integers $n$ and $k$ ( $1<=k<=n<=2200$ ). The second line contains $n$ space-separated integers $a_{1},...,a_{n}$ (![](/uploads/luogu/CF802N/e4754a7339522010b5528b1716cf92621f902f03_fee6c7f5ef9b.png)) — the preparation costs. The third line contains $n$ space-separated integers $b_{1},...,b_{n}$ (![](/uploads/acgo/image/f79bd77465e1d611_39323fdfb82a.jpeg)) — the printing costs.

输出格式

Output the minimum cost of preparation and printing $k$ problems — that is, the minimum possible sum $a_{i1}+a_{i2}+...+a_{ik}+b_{j1}+b_{j2}+...+b_{jk}$ , where $1<=i_{1}<i_{2}<...<i_{k}<=n$ , $1<=j_{1}<j_{2}<...<j_{k}<=n$ and $i_{1}<=j_{1}$ , $i_{2}<=j_{2}$ , ..., $i_{k}<=j_{k}$ .

输入输出样例

输入 #1
8 4
3 8 7 9 9 4 6 8
2 5 9 4 3 8 9 1
输出 #1
32
C++ 编辑器
输入
输出