博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AC日记——Dishonest Sellers Codeforces 779c
阅读量:6892 次
发布时间:2019-06-27

本文共 2455 字,大约阅读时间需要 8 分钟。

C. Dishonest Sellers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ai, and after a week of discounts its price will be bi.

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.

Input

In the first line there are two positive integer numbers n and k (1 ≤ n ≤ 2·105, 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 a1, a2, ..., an (1 ≤ ai ≤ 104) — prices of items during discounts (i.e. right now).

The third line contains sequence of integers b1, b2, ..., bn (1 ≤ bi ≤ 104) — prices of items after discounts (i.e. after a week).

Output

Print the minimal amount of money Igor will spend to buy all n items. Remember, he should buy at least k items right now.

Examples
input
3 1 5 4 6 3 1 5
output
10
input
5 3 3 4 7 10 3 4 5 5 12 5
output
25
Note

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.

 

 思路;

  计算价值然后排序水过(至少k个不是共k个);

 

来,上代码:

#include 
#include
#include
#include
#define maxn 200005using namespace std;struct SortNodeType { int ai,bi,vi;};struct SortNodeType item[maxn];int if_z,n,k,ans;char Cget;inline void in(int &now){ now=0,if_z=1,Cget=getchar(); while(Cget>'9'||Cget<'0') { if(Cget=='-') if_z=-1; Cget=getchar(); } while(Cget>='0'&&Cget<='9') { now=now*10+Cget-'0'; Cget=getchar(); } now*=if_z;}bool cmp(struct SortNodeType a,struct SortNodeType b){ if(a.vi!=b.vi) return a.vi

 

转载于:https://www.cnblogs.com/IUUUUUUUskyyy/p/6551080.html

你可能感兴趣的文章
MySQL大表删除导致服务器变慢的分析
查看>>
windows server操作系统一定要关闭开机磁盘自检
查看>>
Java解析Excel文件
查看>>
MySQL数据类型简介
查看>>
由于未预料的错误,现在无法使用nautilus
查看>>
python很low的三级菜单(六)
查看>>
Go语言之Writer 和 Reader
查看>>
linux 位置参数 特殊变量 read grep 变量赋值
查看>>
spool+sql拼接实现导出结果集为csv格式文件
查看>>
【19】Python工资管理系统
查看>>
HAProxy+Keepalived实现Web服务器负载均衡
查看>>
配置Linux主机SSH无密码访问
查看>>
servlet接收乱码处理方案
查看>>
自动化运维之Ansible的安装与简单入门命令
查看>>
mysql互为主从的环境,更新一条语句同时提交,为什么会出现数据不一致?
查看>>
Vmware软件安装精讲
查看>>
mysql双主模式
查看>>
rpm 安装lamp
查看>>
区块链真的有这么厉害吗?--初识区块链后的感想(一)
查看>>
mongodb Profiling 通过慢查询日志分析查询慢的原因 相应优化
查看>>