hdu 2115 I Love This Game
来源:互联网 发布:mac pro 13.3屏幕尺寸 编辑:程序博客网 时间:2024/05/21 21:41
I Love This Game
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5506 Accepted Submission(s): 1900
Problem Description
Do you like playing basketball ? If you are , you may know the NBA Skills Challenge . It is the content of the basketball skills . It include several parts , such as passing , shooting , and so on. After completion of the content , the player who takes the shortest time will be the winner . Now give you their names and the time of finishing the competition , your task is to give out the rank of them ; please output their name and the rank, if they have the same time , the rank of them will be the same ,but you should output their names in lexicographic order.You may assume the names of the players are unique.
Is it a very simple problem for you? Please accept it in ten minutes.
Is it a very simple problem for you? Please accept it in ten minutes.
Input
This problem contains multiple test cases! Ease test case contain a n(1<=n<=10) shows the number of players,then n lines will be given. Each line will contain the name of player and the time(mm:ss) of their finish.The end of the input will be indicated by an integer value of zero.
Output
The output format is shown as sample below.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.
Sample Input
10Iverson 17:19Bryant 07:03Nash 09:33Wade 07:03Davies 11:13Carter 14:28Jordan 29:34James 20:48Parker 24:49Kidd 26:460
Sample Output
Case #1Bryant 1Wade 1Nash 3Davies 4Carter 5Iverson 6James 7Parker 8Kidd 9Jordan 10
#include<stdio.h>#include <string.h>#include <algorithm>#include <iostream>using namespace std;struct Rank{ char name[30]; int h; int m; int num;};bool cmp(const Rank &r1,const Rank &r2){ if(r1.h !=r2.h) { return r1.h<r2.h; } else if(r1.m !=r2.m) { return r1.m<r2.m; } else { return strcmp(r1.name, r2.name)<0; }}int main( ){ Rank r[11]; int n; int count=1; while (cin>>n && n) { if(count-1) { printf("\n"); } for (int i=0; i<n; i++) { scanf("%s %d:%d",r[i].name,&r[i].h,&r[i].m); } sort(r, r+n, cmp); r[0].num=1; for (int i=1; i<n; i++) { if(r[i].h !=r[i-1].h || r[i].m !=r[i-1].m) { r[i].num=i+1; } else { r[i].num=r[i-1].num; } } printf("Case #%d\n",count++); for (int i=0; i<n; i++) { printf("%s %d\n",r[i].name,r[i].num); } } return 0;}
0 0
- hdu 2115 I Love This Game
- HDU 2115 I Love This Game
- HDU 2115 I Love This Game
- hdu 2115 I Love This Game
- hdu 2115 I Love This Game
- I Love This Game hdu 2115
- HDU 2115 I Love This Game
- hdu 2115 I Love This Game
- HDU--2115 I Love This Game
- hdu 2115 I Love This Game
- hdu-2115-I Love This Game
- hdu 2115 I Love This Game
- HDU 2115 I Love This Game
- I Love This Game 2115
- hdu-2115(结构体,sort) I Love This Game
- HDOJ(HDU) 2115 I Love This Game(排序排序、、、)
- HDU,2215,I Love This Game
- I Love This Game!
- IndexSearcher
- java排序算法
- Linux处理7z文件(压缩)的工具
- 线段树(单点更新) 之 hdu 1754
- Hibernate中session.connection()的替代方法
- hdu 2115 I Love This Game
- android 修改xml实现横屏与竖屏
- linux inittab详解
- hdoj 1097 A hard puzzle
- SSI详解
- 杭电2044第一次超时,一改就过了,但还是不知道第一次为何超时,__int64 必须用,因为数组里的数可能很大,递推1-2:2,1-3:1,1-4:2,1-5:3,1-6:4,
- eclipse中user libraries部署到WEB-INF/lib
- 将GPS信息写入到图片里
- .NET对象生命周期——技术知识