문제2428--Arthur and Table

2428: Arthur and Table

실행시간 제한: 1 Sec  메모리사용 제한: 128 MB
제출: 7  통과: 4
[제출] [채점기록] [묻고답하기]

문제 설명

Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable. In total the table Arthur bought has n legs, the length of the i-th leg is li. Arthur decided to make the table stable and remove some legs. For each of them Arthur determined number di — the amount of energy that he spends to remove the i-th leg. A table with k legs is assumed to be stable if there are more than half legs of the maximum length. For example, to make a table with 5 legs stable, you need to make sure it has at least three (out of these five) legs of the maximum length. Also, a table with one leg is always stable and a table with two legs is stable if and only if they have the same lengths. Your task is to help Arthur and count the minimum number of energy units Arthur should spend on making the table stable.

입력 설명

The first line of the input contains integer $n (1 \leq n \leq 10^5)$ — the initial number of legs in the table Arthur bought. The second line of the input contains a sequence of n integers $l_i (1 \leq l_i \leq 10^5)$, where $l_i$ is equal to the length of the i-th leg of the table. The third line of the input contains a sequence of n integers $d_i (1 \leq d_i \leq 200)$, where $d_i$ is the number of energy units that Arthur spends on removing the i-th leg off the table.

출력 설명

Print a single integer — the minimum number of energy units that Arthur needs to spend in order to make the table stable.

6
2 2 1 1 3 3
4 3 5 5 2 1

8