HDU--2115
2015-06-09 11:53
330 查看
I Love This Game
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6357 Accepted Submission(s): 2175
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.
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.
Sample Input
10 Iverson 17:19 Bryant 07:03 Nash 09:33 Wade 07:03 Davies 11:13 Carter 14:28 Jordan 29:34 James 20:48 Parker 24:49 Kidd 26:46 0
Sample Output
Case #1 Bryant 1 Wade 1 Nash 3 Davies 4 Carter 5 Iverson 6 James 7 Parker 8 Kidd 9 Jordan 10
Author
為傑沉倫
Source
HDU 2007-10 Programming Contest_WarmUp
#include<stdio.h> #include<string.h> struct people{ char name[50]; int time; int rank; } a[11]; char temp[50]; int main() { int n,i,count=0,m,s,j; while(scanf("%d",&n),n) { if(count) printf("\n"); count++; printf("Case #%d\n",count); for(i=1;i<=n;i++) { scanf("%s %d:%d",a[i].name,&m,&s); a[i].time=m*60+s; } for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) { if(a[i].time>a[j].time) { strncpy(temp,a[j].name,50); strncpy(a[j].name,a[i].name,50); strncpy(a[i].name,temp,50); m=a[i].time; a[i].time=a[j].time; a[j].time=m; } } a[1].rank=1; for(i=2;i<=n;i++) if(a[i].time==a[i-1].time) a[i].rank=a[i-1].rank; else a[i].rank=i; for(i=1;i<=n;i++) printf("%s %d\n",a[i].name,a[i].rank); } return 0; }
相关文章推荐
- C3P0具体的配置说明(com.mchange.v2.c3p0.ComboPooledDataSource)
- 【linux】脚 使用 清空文件内容
- 自制游戏(一) 飞行射击游戏
- LA 4850 贪心
- sudo: ./sd_fusing.sh:找不到命令
- iOS——使用自定义字体方法
- 基于heartbeat v2 crm实现基于nfs的mysql高可用集群
- JavaScript的Date()方法使用详解
- android系统新添加字体及java代码中引用
- C# JArray与JObject 的使用
- 新手使用旗正规则引擎
- 文件批量改名(有规律)
- HDU--2060
- 循环写入大数据测试MySQL及SQL server
- js去除所有空格
- DecimalFormat格式化输出
- 一个不错的shell 脚本教程 入门级
- HDU--2060
- ZH奶酪:PHP安装扩展imagick
- Node Callbacks