欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1089L.Lazyland
Lazyland
The kingdom of Lazyland is the home to idlers. These idlers are incredibly lazy and create many problems to their ruler, the mighty King of Lazyland.
Today important jobs for the kingdom () should be performed. Every job should be done by one person and every person can do at most one job. The King allowed every idler to choose one job they wanted to do and the -th idler has chosen the job .
Unfortunately, some jobs may not be chosen by anyone, so the King has to persuade some idlers to choose another job. The King knows that it takes minutes to persuade the -th idler. He asked his minister of labour to calculate the minimum total time he needs to spend persuading the idlers to get all the jobs done. Can you help him?
Input
The first line of the input contains two integers and () — the number of idlers and the number of jobs.
The second line of the input contains integers () — the jobs chosen by each idler.
The third line of the input contains integers () — the time the King needs to spend to persuade the -th idler.
Output
The only line of the output should contain one number — the minimum total time the King needs to spend persuading the idlers to get all the jobs done.
Note
In the first example the optimal plan is to persuade idlers 1, 6, and 8 to do jobs 2, 4, and 6.
In the second example each job was chosen by some idler, so there is no need to persuade anyone.
Samples
8 7
1 1 3 1 5 3 7 1
5 7 4 8 1 3 5 2
10
3 3
3 1 2
5 3 4
0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |