Codeforces Round 311 (Div. 2)
C
Arthur and Table
Codeforces
1900
原题
← BD →
翻译中…

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 $*l*_{*i*}$.

翻译中…

Arthur decided to make the table stable and remove some legs. For each of them Arthur determined number $*d*_{*i*}$ — 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.

翻译中…

Input

翻译中…

The first line of the input contains integer $*n*$ ($1 ≤ *n* ≤ 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 ≤ *l*_{*i*} ≤ 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 ≤ *d*_{*i*} ≤ 200$), where $*d*_{*i*}$ is the number of energy units that Arthur spends on removing the $*i*$-th leg off the table.

翻译中…

Output

翻译中…

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

翻译中…

样例

Input #1
2
1 5
3 2
Output #1
2
InputCopy OutputCopy
Input #2
3
2 4 4
1 1 1
Output #2
0
InputCopy OutputCopy
Input #3
6
2 2 1 1 3 3
4 3 5 5 2 1
Output #3
8
InputCopy OutputCopy
题目信息
题号
557C
时间限制
1 s
内存限制
256 MB
标签
暴力
数据结构
动态规划
贪心
数学
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。