#abc360c. C - Move It
C - Move It
Score : points
问题陈述
有 个编号为 到 的盒子和 个编号为 到 的物品。物品 位于盒子 并且重量为 。
你可以重复执行选择一个物品并将其移动到另一个盒子的操作,次数可以是零次或多次。如果被移动的物品重量为 ,则该操作的成本为 。
找出使每个盒子恰好包含一个物品所需的最小总成本。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are boxes numbered to and items numbered to . Item is in box and has a weight of .
You can repeatedly perform the operation of choosing an item and moving it to another box zero or more times. If the weight of the item being moved is , the cost of the operation is .
Find the minimum total cost required to make each box contain exactly one item.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the minimum total cost required to make each box contain exactly one item.
Sample Input 1
5
2 2 3 3 5
33 40 2 12 16
Sample Output 1
35
With the following two moves, you can make each box contain exactly one item:
- Move item from box to box . The cost is .
- Move item from box to box . The cost is .
The total cost of these two moves is . It is impossible to make each box contain exactly one item with a cost less than , so print .
Sample Input 2
12
3 6 7 4 12 4 8 11 11 1 8 11
3925 9785 9752 3587 4013 1117 3937 7045 6437 6208 3391 6309
Sample Output 2
17254