HDU 2115 I Love This Game
来源:互联网 发布:淘宝挂拍摆衣服技巧 编辑:程序博客网 时间:2024/06/07 02:55
http://acm.hdu.edu.cn/showproblem.php?pid=2115
I Love This Game
TimeLimit: 3000/1000 MS(Java/Others)Total Submission(s):2968
Problem Description
Do you like playing basketball ? If youare , you may know the NBA Skills Challenge . It is the content ofthe basketball skills . It include several parts , such as passing, shooting , and so on. After completion of the content , theplayer who takes the shortest time will be the winner . Now giveyou their names and the time of finishing the competition , yourtask is to give out the rank of them ; please output their name andthe rank, if they have the same time , the rank of them will be thesame ,but you should output their names in lexicographic order.Youmay assume the names of the players are unique.
Is it a very simple problem for you? Please accept it in tenminutes.
Is it a very simple problem for you? Please accept it in tenminutes.
Input
This problem contains multiple testcases! Ease test case contain an(1<=n<=10) shows the number ofplayers,then n lines will be given. Each line will contain the nameof player and the time(mm:ss) of their finish.The end of the inputwill be indicated by an integer value of zero.
Output
The output format is shown as samplebelow.
Please output the rank of all players, the output format is shownas sample below;
Output a blank line between two cases.
Please output the rank of all players, the output format is shownas sample below;
Output a blank line between two cases.
Sample Input
10 Iverson17:19 Bryant 07:03 Nash 09:33 Wade 07:03 Davies 11:13 Carter 14:28Jordan 29:34 James 20:48 Parker 24:49 Kidd 26:46 0
Sample Output
Case #1Bryant 1 Wade 1 Nash 3 Davies 4 Carter 5 Iverson 6 James 7 Parker 8Kidd 9 Jordan 10
Author
為傑沉倫
Source
HDU 2007-10 Programming Contest_WarmUp
Recommend
威士忌
题意:按照给出的时间排序。有两点注意:每两个输出之间空一行、排名会出现并列。
分析:用结构体,把信息捆绑在一起,记录时间,排序输出即可。这个题的排序,我建议用冒泡排序,因为qsort还得写cmp函数。我的代码0ms过的,从网上找了一个用qsort的,15ms^-^
代码如下:
#include<stdio.h>
struct pp
{
char w[20];
int shi;
int fen;
int shijian;
int paiming;
};
pp ans[11];
pp temp;
int main()
{
int n,i,j,m=1;
while(scanf("%d",&n)!=EOF&&n!=0)
{
for(i=0;i<n;i++)
{
scanf("%s%d:%d",ans[i].w,&ans[i].shi,&ans[i].fen);
}
for(i=0;i<n;i++)
ans[i].shijian=60*ans[i].shi+ans[i].fen;
for(i=0;i<n;i++)
{
for(j=0;j<n-1-i;j++) //冒泡排序好久不用了,j的for循环条件写错了,wrong个无数次。。
{
if(ans[j].shijian>ans[j+1].shijian)
{
temp=ans[j];
ans[j]=ans[j+1];
ans[j+1]=temp;
}
}
}
ans[0].paiming=1;
for(i=1;i<n;i++)
{
if(ans[i-1].shijian==ans[i].shijian)ans[i].paiming=ans[i-1].paiming;
else ans[i].paiming=i+1;
}
if(m!=1)
printf("\n");
printf("Case #%d\n",m++);
for(i=0;i<n;i++)
printf("%s %d\n",ans[i].w,ans[i].paiming);
}
return 0;
}
struct pp
{
};
pp ans[11];
pp temp;
int main()
{
}
阅读全文
0 0
- HDU 2115 I Love This Game
- This head I hold
- HDOJ 1846 Brave Game
-  
-
- HDU 1242 Rescue
- POJ 1753 Flip Game
- hdu 2147 kiki's game(博奕)
- hdu 1065 I Think&…
- (HDU)1022 Train Problem I
- HDU 1754 I Hate It(线段树模版…
- hdu 1858 Max Partial Value I(DP…
- HDU 1075 What Are You Talking …
- HDOJ 1171 Big Event in HDU
- ZZULI_SummerPractice(3) HDU 1…
- HDU 1579 Function Run Fun
- HDU 1405 The Last Practice
- HDU 2050 折线分割平面
- HDU 2135 Rolling table
- HDU 2131 Probability
- 行人属性--HydraPlus-Net: Attentive Deep Features for Pedestrian Analysis
- 作为QA角色去产品部门,想要了解某个产品部门的研发情况,应该从哪几个方面入手?
- SQL语句的学习(初)
- HDU 2115 I Love This Game
- HDU 2109 Fighting for HDU
- HDU 2103 Family planning
- OpenStack Tacker介绍
- 卡方检验原理及应用
- HDU 2098 分拆素数和
- HDU 2093 考试排名
- HDU 2088 Box of Bricks
- 一个web项目web.xml的配置中<context-param>配置作用