AmazonOA #254
Make Array Distinct (Selling Shoes )
估计困难可在线判题
Each product's size can only increase, and each unit of increase costs that product's cost. All final sizes must be distinct; find the minimum total cost. Every product is kept, and there is no upper limit on the final sizes.
输入格式
The first line contains n, the second line size, and the third line cost. This page gives no numeric bounds, but the original text explicitly links to the same problem amazon-get-minimal-cost.md, whose full bounds are added here: 1≤n≤200000, 1≤size≤10^9, 1≤cost≤10000.
输出格式
Output a single integer, the answer.
样例 1
输入:
2
1 1
1 2
输出:
1
样例 2
输入:
4
2 3 3 2
2 4 5 1
输出:
7
样例 3
输入:
2
1 10
10000 1
输出:
0
样例说明
The answers are 1, 7 and 0. Every unit is charged; you cannot just take the total cost minus the cost of each item as it leaves the heap.