1001 Jump and Jump...

Jump and Jump...


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


问题描述

   
   
    
    n
   
   小孩在比赛跳远,看谁跳的最远。每个小孩可以跳3次,这个小孩的成绩就是三次距离里面的最大值。例如,一个小孩跳3次的距离分别时10, 30和20,那么这个小孩的成绩就是30。给出每个孩子三次跳的距离,问最终每个孩子的排名是多少。
输入描述
输入文件的第一行有一个整数
   
   
    
    T (1T100)
   
   ,表示测试数据的组数。对于每组测试数据:第一行包括一个整数
   
   
    
    n (2n3)
   
   , 表示孩子的数目. 接下来
   
   
    
    n
   
   行, 每行包含三个整数
   
   
    
    ai,bi
   
   
   
   
    
    ci
   
    (
   
   
    
    1ai,bi,ci,300
   
   ), 表示第
   
   
    
    i
   
   个小孩每次的跳的距离。输入数据保证每个孩子的成绩互不相同。
输出描述
对于每组数据,输出一行包含
   
   
    
    n
   
   个整数,用一个空格隔开。第
   
   
    
    i
   
   个数表示第
   
   
    
    i
   
   个小孩的最终名次。
输入样例
2
3
10 10 10
10 20 30
10 10 20
2
3 4 1
1 2 1
输出样例
3 1 2
1 2
提示:
对于第一组数据,3个孩子的成绩分别时10, 20和30。因此他们最终排名依次是3, 1和2.



本人英语渣!看中文题水过的!惯例BestCoder第一题都不难的
其实是一个关于排序的问题.选择每个人成绩的Max作为这个人的成绩
再把每个人的成绩比较,得出排名,唯一有点疑惑的地方就是,按照
输入顺序输出每个人成绩的排名.我这里用了b,c两个数组,开头存的是
每个人的最终成绩.然后b数组排序,用一个二重循环,如果c数组与b数组
里面的数对应相等.输出n-k的下标差!最小的当然是最后一名了 !囧!

import java.io.*;
import java.util.*;

public class Main
{

	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int t = input.nextInt();
		for (int i = 0; i < t; i++)
		{
			int n = input.nextInt();
			int a[][] = new int[n][3]; // 记录三次跳远的成绩
			for (int j = 0; j < n; j++)
			{
				a[j][0] = input.nextInt();
				a[j][1] = input.nextInt();
				a[j][2] = input.nextInt();
			}
			int b[] = new int[n];
			int c[] = new int[n];
			for (int j = 0; j < n; j++)
			{
				int max = a[j][0];
				if (max < a[j][1])
				{
					max = a[j][1];
				}
				if (max < a[j][2])
				{
					max = a[j][2];
				}
				b[j] = max;
				c[j] = max;
			}
			Arrays.sort(b);
			for (int j = 0; j < n; j++)
			{
				for (int k = 0; k < n; k++)
				{
					if (c[j] == b[k])
					{
						if(j!=n-1)
						{
							System.out.print(n - k + " "); 
						}
						else 
						{
							System.out.println(n-k);
						}
					}
				}
			}
		}
	}

}


英文题在下面==,原谅我这样排版,c博客不好用==.

Jump and Jump...


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


Problem Description
   
   
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.
 
Input
   
   
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).
 
Output
   
   
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.
 
Sample Input
   
   
2 3 10 10 10 10 20 30 10 10 20 2 3 4 1 1 2 1
 
Sample Output
   
   
3 1 2 1 2
Hint
For the first case, the farthest distance each kid can jump is 10, 30 and 20. So the rank is 3, 1, 2.
 
Statistic |  Submit |  Clarifications |  Back


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值