2018ACM-CCPC湖南湘潭邀请赛 Sorting

Sorting

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


Problem Description
Bobo has n tuples (a1,b1,c1),(a2,b2,c2),,(an,bn,cn).
He would like to find the lexicographically smallest permutation p1,p2,,pn of 1,2,,n such that for i{2,3,,n} it holds that
api1+bpi1api1+bpi1+cpi1api+bpiapi+bpi+cpi.

 

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 ai, bi and ci.
 

Output
For each test case, print n integers p1,p2,,pn seperated by spaces.
DO NOT print trailing spaces.

## Constraint

* 1n103
* 1ai,bi,ci2×109
* The sum of n does not exceed 104.
 

Sample Input

21 1 11 1 221 1 21 1 131 3 12 2 13 1 1
 
Sample Output

2 11 21 2 3

 

//(a1+b1)*c2<=(a2+b2)*c1
//如果后面小了就更换,相同,i小在前
//用longlongint,不然wa
#include 
using namespace std;
struct node
{
    long long int a,b,c;
}p[10005];
int q[10005];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%lld%lld%lld",&p[i].a,&p[i].b,&p[i].c);
            q[i]=i;
        }
        for(int i=1;i

你可能感兴趣的:(2018ACM-CCPC湖南湘潭邀请赛 Sorting)