Shoemaker's Job Order
InterviewTime limit2sMemory limit512 MB
Order N jobs to minimize the total fine paid while each job waits, using the shortest processing time per fine ratio first, with lexicographically smallest ties.
Problem
A shoemaker has jobs ordered by customers waiting in his shop. He works on one job at a time, and job takes days to finish. is an integer with .
For every day that passes before job starts, the shoemaker pays a fine of cents. is an integer with . Find the job order that makes the total fine as small as possible.
Once an order is fixed, job starts after a delay equal to the sum of the durations of the jobs placed before it. The total fine is the sum, over all jobs, of that delay multiplied by .
The shoemaker cannot run two jobs on the same day. After he starts job , he cannot work on any other job until job is finished.
Input
The first line contains the integer with .
The -th of the next lines contains and , separated by a space.
Output
Print, on one line, the job order that gives the smallest total fine. Each job is written as its input number from to , and consecutive numbers are separated by a single space. If several orders reach the smallest total fine, print the lexicographically smallest one.