#1379
Unrated
Lazyland
시간 제한
2s
메모리 제한
512MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

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 (knk \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 ii-th idler has chosen the job aia_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 bib_i 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?

입력

The first line of the input contains two integers nn and kk (1kn1051 \le k \le n \le 10^5) — the number of idlers and the number of jobs.

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1aik1 \le a_i \le k) — the jobs chosen by each idler.

The third line of the input contains nn integers b1,b2,,bnb_1, b_2, \ldots, b_n (1bi1091 \le b_i \le 10^9) — the time the King needs to spend to persuade the ii-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.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.