CF802N.April Fools' Problem (medium)

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

The preparation of a problem on day ii (at most one per day) costs aia_{i} CHF, and the printing of a problem on day ii (also at most one per day) costs bib_{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 nn and kk ( 1<=k<=n<=22001<=k<=n<=2200 ). The second line contains nn space-separated integers a1,...,ana_{1},...,a_{n} () — the preparation costs. The third line contains nn space-separated integers b1,...,bnb_{1},...,b_{n} () — the printing costs.

输出格式

Output the minimum cost of preparation and printing kk problems — that is, the minimum possible sum ai1+ai2+...+aik+bj1+bj2+...+bjka_{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 i1<=j1i_{1}<=j_{1} , i2<=j2i_{2}<=j_{2} , ..., ik<=jki_{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 11 and print it on day 11 , prepare the second problem on day 22 and print it on day 44 , prepare the third problem on day 33 and print it on day 55 , and prepare the fourth problem on day 66 and print it on day 88 .

首页