cswork / OA打开练习工作台

IBMOA #65

Rearrange Server Load

估计简单可在线判题

考点(AI 标注)贪心调度原地数组

With serverCapacity fixed, rearrange serverLoad to minimize Σ capacity[i]×load[i]. If there are multiple minimum-resource arrangements, you must return the lexicographically smallest load array. The latter requirement comes directly from the original statement body; the compiled catalog lost that sentence.

输入格式

The first line contains n, the second line contains n capacity values, and the third line contains n load values. This site adds 1≤n≤200000, and the elements of both arrays are integers in −10^9..10^9, with duplicates and negative values allowed.

输出格式

Output n integers: the unique lexicographically smallest optimal load arrangement.

样例 1

输入:

3
4 5 6
1 2 3

输出:

3 2 1

样例 2

输入:

5
1 2 3 3 3
2 2 4 5 6

输出:

6 5 2 2 4

样例 3

输入:

2
1 1
2 1

输出:

1 2

样例说明

The outputs of the three public examples are, in order: 3 2 1; 6 5 2 2 4; 1 2. These answers were verified by independent enumeration or direct simulation.