305785: CF1089L. Lazyland

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Lazyland

题意翻译

懒人国是$n$位懒人的家,他们及其懒惰,给他们的统治者——懒人国国王平添许多麻烦。 今天,他们要完成$k$份懒人国中重要的工作$(k\le n)$;每份工作只能被一个人做,每个人最多做一件事。国王允许每一位懒人选择一位自己想做的工作,并且第$i$个懒人选了第$a_i$个工作。 不幸的是,有些工作可能不会被任何人选到,所以国王就得劝一些懒人换一个工作。国王知道劝第$i$个懒人需要$b_i$分钟。他想要劳动部部长计算出为了使每个工作都被做所需要说服懒人的最短时间。你能帮帮他吗? By U123268 @Conch_Man

题目描述

The kingdom of Lazyland is the home to $ n $ idlers. These idlers are incredibly lazy and create many problems to their ruler, the mighty King of Lazyland. Today $ k $ important jobs for the kingdom ( $ k \le 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 $ i $ -th idler has chosen the job $ a_i $ . 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 $ b_i $ minutes to persuade the $ i $ -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?

输入输出格式

输入格式


The first line of the input contains two integers $ n $ and $ k $ ( $ 1 \le k \le n \le 10^5 $ ) — the number of idlers and the number of jobs. The second line of the input contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 1 \le a_i \le k $ ) — the jobs chosen by each idler. The third line of the input contains $ n $ integers $ b_1, b_2, \ldots, b_n $ ( $ 1 \le b_i \le 10^9 $ ) — the time the King needs to spend to persuade the $ i $ -th idler.

输出格式


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.

输入输出样例

输入样例 #1

8 7
1 1 3 1 5 3 7 1
5 7 4 8 1 3 5 2

输出样例 #1

10

输入样例 #2

3 3
3 1 2
5 3 4

输出样例 #2

0

说明

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.

Input

题意翻译

懒人国是$n$位懒人的家,他们及其懒惰,给他们的统治者——懒人国国王平添许多麻烦。 今天,他们要完成$k$份懒人国中重要的工作$(k\le n)$;每份工作只能被一个人做,每个人最多做一件事。国王允许每一位懒人选择一位自己想做的工作,并且第$i$个懒人选了第$a_i$个工作。 不幸的是,有些工作可能不会被任何人选到,所以国王就得劝一些懒人换一个工作。国王知道劝第$i$个懒人需要$b_i$分钟。他想要劳动部部长计算出为了使每个工作都被做所需要说服懒人的最短时间。你能帮帮他吗? By U123268 @Conch_Man

加入题单

上一题 下一题 算法标签: