2018-2019 ICPC, NEERC, Northern Eurasia Finals (Unrated, Online Mirror, ICPC Rules, Teams Preferred) |
---|

Finished |

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

L. Lazyland

time limit per test

1.5 secondsmemory limit per test

512 megabytesinput

standard inputoutput

standard outputThe 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?

Input

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.

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.

Examples

Input

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

Output

10

Input

3 3 3 1 2 5 3 4

Output

0

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.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/15/2019 03:43:53 (e2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|