#P16430. 危机重重
危机重重
Background
Algo Beat has run into a series of crises. They plan to send several people to resolve the crises in order to ensure national security.
Problem Description
There are people as candidates to resolve the crisis. However, they will only work seriously if, among the people sent, everyone has the same diligence value . You may also perform any number of upgrade operations (possibly times):
- Choose an , and spend dollars to increase by .
The king wants to select people to send, but he wants to minimize the total cost, so he asks you, who can program, to help him.
Input Format
The first line contains two integers and .
The second line contains integers , representing the initial diligence values.
The third line contains integers , representing the cost required for an upgrade.
Output Format
Output one integer in a single line, representing the minimum cost.
5 4
1 2 1 2 1
6 3 4 5 4
8
Hint
Subtask #0 is the sample and is worth points.
Constraints
This problem uses bundled testdata.
For all testdata, it holds that:
- , , , .
::cute-table{tuack}
| Subtask ID | Special Property | Score | |
|---|---|---|---|
| None | |||
| A | |||
| B | |||
| None |
- Special Property A: It is guaranteed that .
- Special Property B: It is guaranteed that is a permutation of .
Translated by ChatGPT 5