#P1223. 排队接水
排队接水
Description
There are people lining up at a faucet. Suppose the time each person needs to fill water is . Please write a program to find an ordering of these people that minimizes the average waiting time of all people.
A person's waiting time does not include their own filling time.
If two people have the same filling time, the one with the smaller index should be placed earlier.
Input Format
The first line contains an integer .
The second line contains integers. The -th integer denotes the -th person's filling time .
Output Format
Output two lines. The first line is an ordering that yields the minimum average waiting time. The second line is the average waiting time under this ordering (rounded to two decimal places).
10
56 12 1 99 1000 234 33 55 99 812
3 2 7 8 1 4 9 6 10 5
291.90
Hint
Constraints: , . The are not guaranteed to be distinct.
Translated by ChatGPT 5
京公网安备 11011102002149号