April Fools' Problem (medium)

题意翻译

给定两个长度为 $n$ 的序列 $a_1, a_2, \ldots, a_n$ 和 $b_1, b_2, \ldots b_n$。要求选出 $i_1, i_2, \ldots, i_k$ 和 $j_1, j_2, \ldots, j_k$,满足 * $1\leq i_1< i_2<\ldots< i_k$,$1\leq j_1< j_2<\ldots< j_k$。 * $i_p\leq j_p$($1\leq p \leq k$)。 最小化 $\sum_{p=1}^k a_{i_p}+b_{j_p}$ 的值。

题目描述

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} $ (![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF802N/e4754a7339522010b5528b1716cf92621f902f03.png)) — the preparation costs. The third line contains $ n $ space-separated integers $ b_{1},...,b_{n} $ (![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF802N/a8ea7f0bb23797e6537e2f5e7c007f9d7fcd2a0d.png)) — 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}&lt;i_{2}&lt;...&lt;i_{k}<=n $ , $ 1<=j_{1}&lt;j_{2}&lt;...&lt;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

说明

In the sample testcase, one optimum solution is to prepare the first problem on day $ 1 $ and print it on day $ 1 $ , prepare the second problem on day $ 2 $ and print it on day $ 4 $ , prepare the third problem on day $ 3 $ and print it on day $ 5 $ , and prepare the fourth problem on day $ 6 $ and print it on day $ 8 $ .