Under construction

Still being built. Things may change

Shoemaker's Job Order

Interview

Time limit2sMemory limit512 MB

Summary
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.
Level

Medium5 of 10

Topics
Greedy, Sorting
Solved
No attempts yet

Problem

A shoemaker has NN jobs ordered by customers waiting in his shop. He works on one job at a time, and job ii takes TiT_i days to finish. TiT_i is an integer with 1≤Ti≤10001 \le T_i \le 1000.

For every day that passes before job ii starts, the shoemaker pays a fine of SiS_i cents. SiS_i is an integer with 1≤Si≤100001 \le S_i \le 10000. Find the job order that makes the total fine as small as possible.

Once an order is fixed, job ii 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 SiS_i.

The shoemaker cannot run two jobs on the same day. After he starts job ii, he cannot work on any other job until job ii is finished.

Input

The first line contains the integer NN with 1≤N≤10001 \le N \le 1000.

The ii-th of the next NN lines contains TiT_i and SiS_i, 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 11 to NN, and consecutive numbers are separated by a single space. If several orders reach the smallest total fine, print the lexicographically smallest one.

Examples3

  1. Example 1

    Input
    4
    3 4
    1 1000
    2 2
    5 5
    
    Expected output
    2 1 3 4
    
  2. Example 2

    Input
    1
    1000 10000
    
    Expected output
    1
    
  3. Example 3

    Input
    2
    1 10000
    1000 1
    
    Expected output
    1 2