HDU 5162 简单排序
来源:互联网 发布:网件的访客网络 编辑:程序博客网 时间:2024/06/15 13:52
Jump and Jump...
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 219 Accepted Submission(s): 161
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 integerT (1≤T≤100) , indicating the number of test cases. For each test case: The first line contains an integern (2≤n≤3) , indicating the number of kids. For the next n lines, each line contains three integers ai,bi and ci (1≤ai,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 containn integers, separated by one space. The i -th integer indicating the rank of i -th kid.
Sample Input
2310 10 1010 20 3010 10 2023 4 11 2 1
Sample Output
3 1 21 2HintFor the first case, the farthest distance each kid can jump is 10, 30 and 20. So the rank is 3, 1, 2.
Source
BestCoder Round #27
//// 5162 简单排序.cpp// HDOJ//// Created by cipher on 15/1/28.// Copyright (c) 2015年 cipher. All rights reserved.//#include <iostream>#include <stdio.h>#include <algorithm>using namespace std;#define N 305int a[N],b[N];int main(){ int t,i,j,n,max,maxPos,x,k; scanf("%d",&t); while (t--) { scanf("%d",&n); for (i=0; i<n; i++) { max=-1; for (j=0; j<3; j++) { scanf("%d",&x); if(max<x){ max = x; } } a[i]=max; } k=1; for (i=0; i<n; i++) { max=a[0]; maxPos=0; for (j=0; j<n; j++) { if(a[j]>max) { max=a[j]; maxPos=j; } } b[maxPos]=k++; a[maxPos]=-1; } printf("%d",b[0]); for (i=1; i<n; i++) { printf(" %d",b[i]); } printf("\n"); } return 0;}
0 0
- HDU 5162 简单排序
- HDU 2535 Vote 简单排序
- HDU--1236 -- 排名 [使用库函数简单排序]
- HDU-1285简单的拓扑排序
- hdu 1285 拓扑排序(简单)
- HDU 1106 排序(简单分类模拟)
- HDU 2187 简单贪心--直接排序
- hdu 1106 排序(简单处理)
- HDU 1040数组输出格式&简单排序
- hdu 2000 ASCII码排序 (简单排序)
- HDOJ(HDU) 2109 Fighting for HDU(简单排序比较)
- hdu 1285 确定比赛名次 (简单的拓扑排序)
- hdu 1285 确定比赛名次 简单的拓扑排序
- hdu 1392 简单凸包 极角排序
- HDU 1285 确定比赛名次(简单拓扑排序)
- HDU 3342 Legal or Not(简单拓扑排序判定)
- HDU 1285 确定比赛名次(最简单拓扑排序)
- HDU-1465-不容易系列之一(简单全错位排序)
- Android 图片缓存处理
- unity优化的一些建议(代码+文字)
- JavaScript判断一个对象是否为空,未定义
- PHP面向对象(OOP)编程完全教程:4.如何抽象出一个类?
- 怎么跳出MySQL的10个大坑
- HDU 5162 简单排序
- 未来四年的计划目标
- iOS学习之WebView的使用--实现打开网页
- 第二十六次codeforces竞技结束 #286 Div 2
- Linux下解压命令大全 解压缩 tar bz2 zip tar.gz gz
- over(Partition by...) ORACLE函数
- ubuntu下使用pre-trained模型测试caffe,找不到caffe 和 protobuf的错误
- Android 如何使用GPU硬件加速
- Codeforces 508D Tanya and Password 欧拉通路Euler