F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Sorting

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6539    Accepted Submission(s): 1567


Problem Description
Bobo has $n$ tuples $(a_1, b_1, c_1), (a_2, b_2, c_2), \dots, (a_n, b_n, c_n)$.
He would like to find the lexicographically smallest permutation $p_1, p_2, \dots, p_n$ of $1, 2, \dots, n$ such that for $i \in \{2, 3, \dots, n\}$ it holds that
$$\frac{a_{p_{i - 1}} + b_{p_{i - 1}}}{a_{p_{i - 1}} + b_{p_{i - 1}} + c_{p_{i - 1}}} \leq \frac{a_{p_i} + b_{p_i}}{a_{p_i} + b_{p_i} + c_{p_i}}.$$
 

Input
The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains an integer $n$.
The $i$-th of the following $n$ lines contains $3$ integers $a_i$, $b_i$ and $c_i$.
 

Output
For each test case, print $n$ integers $p_1, p_2, \dots, p_n$ seperated by spaces.
DO NOT print trailing spaces.

## Constraint

* $1 \leq n \leq 10^3$
* $1 \leq a_i, b_i, c_i \leq 2 \times 10^9$
* The sum of $n$ does not exceed $10^4$.
 

Sample Input
2 1 1 1 1 1 2 2 1 1 2 1 1 1 3 1 3 1 2 2 1 3 1 1
 

Sample Output
2 1 1 2 1 2 3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-03 00:12:26, Gzip enabled