CodeForces - 1089L 贪心

在懒人国,国王需要分配k项任务给n个懒人,每个懒人只能选择一项任务。已知每个懒人选的任务和说服他们改变任务所需的时间。题目要求计算最小的总说服时间以确保所有任务完成。输入包括任务数、懒人数、每个懒人选的任务和说服时间,输出是最小总说服时间。第一例中,需要说服第1、6、8号懒人改做其他任务。第二例中,所有任务都有人选,无需说服。
摘要由CSDN通过智能技术生成

The kingdom of Lazyland is the home to nn idlers. These idlers are incredibly lazy and create many problems to their ruler, the mighty King of Lazyland.

Today kk important jobs for the kingdom (k≤nk≤n) 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 ii-th idler has chosen the job aiai.

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 bibi minutes to persuade the ii-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 nn and kk (1≤k≤n≤1051≤k≤n≤105) — the number of idlers and the number of jobs.

The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值