HDU 5162

題目簡單,主要是對名次的處理。下面的代碼巧妙的對名次 那一塊作了處理。若是 三個同窗的 最長距離分別是10 20 30,而後 分別對應的是x[1],x[2],x[3];分別比較,當x[i]>x[j] 時,y[i]++,當全部的成績都比較完以後,再對y[i]+1即獲得 其排名。




Jump and Jump...

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


php

Problem Descriptionide

There are n kids and they want to know who can jump the farthest. For each kid, he can jump three times and the distance he jumps is maximum distance amount all the three jump. For example, if the distance of each jump is (10, 30, 20), then the farthest distance he can jump is 30. Given the distance for each jump of the kids, you should find the rank of each kid.spa

 


Inputorm

There are multiple test cases. The first line of input contains an integer T (1T100), indicating the number of test cases. For each test case: The first line contains an integer n (2n3), indicating the number of kids. For the next n lines, each line contains three integers ai,bi and ci (1ai,bi,ci,300), indicating the distance for each jump of the i-th kid. It's guaranteed that the final rank of each kid won't be the same (ie. the farthest distance each kid can jump won't be the same).three

 


Outputip

For each test case, you should output a single line contain n integers, separated by one space. The i-th integer indicating the rank of i-th kid.ci

 


Sample Inputget

2
3
10 10 10
10 20 30
10 10 20
2
3 4 1
1 2 1

 


Sample Outputinput

3 1 2
1 2HintFor the first case, the farthest distance each kid can jump is 10, 30 and 20. So the rank is 3, 1, 2.

 


Sourcestring

BestCoder Round #27

 

  #include<cstdio>
  #include<cstring>
  #include<algorithm>
  using namespace std;
 int main()
 {
    int a,b,c,t,n,x[4],i,j,y[4];
      scanf("%d",&t);
      while (t--)
     {
         scanf("%d",&n);
         for (i=1;i<=n;i++)
         {
             scanf("%d%d%d",&a,&b,&c);
             x[i]=max(max(a,b),c);
         }
         memset(y,0,sizeof(y));
         for (i=1;i<=n;i++)
         {
             for (j=1;j<=n;j++)
             if (x[i]<x[j]) y[i]++;  /*對名次進行處理*/
         }
         for (i=1;i<n;i++) printf("%d ",y[i]+1);
         printf("%d\n",y[n]+1);
     }
     return 0;
 }
相關文章
相關標籤/搜索