Jump and Jump... HDU 5162
来源:互联网 发布:手机淘宝评价管理 编辑:程序博客网 时间:2024/05/18 01:50
Jump and Jump...
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 664 Accepted Submission(s): 370
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.
很粗暴的方法,开两个数组,存储好每个人的最远距离,把一个数组排好序后,和另一个个数组比较,得出名次关系
#include <iostream>#include <cstring>#include <algorithm>using namespace std;int T,sum[105],a,b,c,n,i,j,temp[105];int main(){ cin >> T; while(T--) { cin >> n; memset(sum,0,sizeof(int)*105); memset(temp,0,sizeof(int)*106); for(i = 0;i < n;i++) { cin >> a >>b >> c; sum[i] = max(max(a,b),c); temp[i] = sum[i]; } for(i = 0;i < n;i++) for(j = 0;j < n - 1 - i;j++) if(sum[j] < sum[j+1]) { sum[j]+=sum[j + 1]; sum[j+1] = sum[j] - sum[j+1]; sum[j] = sum[j] - sum[j+1]; } for(i = 0;i < n;i++) for(j = 0;j < n;j++) if(sum[j] == temp[i]) if(!i) cout << j+1; else cout << " " << j+1; cout << endl; } return 0 ;}
0 0
- HDU 5162 Jump and Jump...
- hdu 5162 Jump and Jump...
- Jump and Jump... HDU 5162
- HDU 5162Jump and Jump...
- hdu 5162 Jump and Jump...(模拟)
- hdu 5612 Jump and Jump
- 【BestCoder】 HDOJ 5162 Jump and Jump...
- 1001Jump and Jump...
- 1001 Jump and Jump...
- Jump and Jump...
- 【CUGBACM15级BC第27场 A】hdu 5162 Jump and Jump...
- Jump
- Jump
- Jump
- jump
- Jump
- jump
- Jump
- Wins2003系统中Apache性能优化方法
- 如何导出树结构清晰的代码机构目录
- suse11 Linux系统下如何设置文件共享
- Oracle乱码
- 求二进制中1的个数
- Jump and Jump... HDU 5162
- CART分类与回归树的原理与实现
- Assembling Features Reading Features
- IOS中自动布局autoresizing
- 删除链表中的重复节点、剩余节点逆序输出
- CodeForces 514D R2D2 and Droid Army
- 编程之美3.3——类似——两个字符串的最长公共子序列(LCS)
- 【树形dp】Codeforces 238C World Eater Brothers
- zoj 3601 Unrequited Love(STL,灵活题)