链接:https://codeforces.com/problemset/problem/1151/D
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of nn high school students numbered from 11 to nn. Initially, each student ii is on position ii. Each student ii is characterized by two numbers — aiai and bibi. Dissatisfaction of the person ii equals the product of aiai by the number of people standing to the left of his position, add the product bibi by the number of people standing to the right of his position. Formally, the dissatisfaction of the student ii, which is on the position jj, equals ai⋅(j−1)+bi⋅(n−j)ai⋅(j−1)+bi⋅(n−j).
The director entrusted Stas with the task: rearrange the people in the queue so that minimize the total dissatisfaction.
Although Stas is able to solve such problems, this was not given to him. He turned for help to you.
Inp