A10777 | Dishonest Sellers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Igor found out discounts in a shop and decided to buy $n$ items. Discounts at the store will last for a week and Igor knows about each item that its price now is $a_{i}$ , and after a week of discounts its price will be $b_{i}$ .
Not all of sellers are honest, so now some products could be more expensive than after a week of discounts.
Igor decided that buy at least $k$ of items now, but wait with the rest of the week in order to save money as much as possible. Your task is to determine the minimum money that Igor can spend to buy all $n$ items.
Not all of sellers are honest, so now some products could be more expensive than after a week of discounts.
Igor decided that buy at least $k$ of items now, but wait with the rest of the week in order to save money as much as possible. Your task is to determine the minimum money that Igor can spend to buy all $n$ items.
输入格式
In the first line there are two positive integer numbers $n$ and $k$ ( $1<=n<=2·10^{5}$ , $0<=k<=n$ ) — total number of items to buy and minimal number of items Igor wants to by right now.
The second line contains sequence of integers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=10^{4}$ ) — prices of items during discounts (i.e. right now).
The third line contains sequence of integers $b_{1},b_{2},...,b_{n}$ ( $1<=b_{i}<=10^{4}$ ) — prices of items after discounts (i.e. after a week).
The second line contains sequence of integers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=10^{4}$ ) — prices of items during discounts (i.e. right now).
The third line contains sequence of integers $b_{1},b_{2},...,b_{n}$ ( $1<=b_{i}<=10^{4}$ ) — prices of items after discounts (i.e. after a week).
输出格式
Print the minimal amount of money Igor will spend to buy all $n$ items. Remember, he should buy at least $k$ items right now.
输入输出样例
输入 #1
3 1 5 4 6 3 1 5
输出 #1
10
输入 #2
5 3 3 4 7 10 3 4 5 5 12 5
输出 #2
25
In the first example Igor should buy item 3 paying 6. But items 1 and 2 he should buy after a week. He will pay 3 and 1 for them. So in total he will pay $6+3+1=10$ .
In the second example Igor should buy right now items 1, 2, 4 and 5, paying for them 3, 4, 10 and 3, respectively. Item 3 he should buy after a week of discounts, he will pay 5 for it. In total he will spend $3+4+10+3+5=25$ .
In the second example Igor should buy right now items 1, 2, 4 and 5, paying for them 3, 4, 10 and 3, respectively. Item 3 he should buy after a week of discounts, he will pay 5 for it. In total he will spend $3+4+10+3+5=25$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted