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 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}$ () — the preparation costs. The third line contains $n$ space-separated integers $b_{1},...,b_{n}$ () — 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
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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted