http://acm.hdu.edu.cn/showproblem.php?pid=2115

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

时间复杂度:$O(N * logN)$

代码:

#include <bits/stdc++.h>
using namespace std; int N; struct Player {
char name[300];
int hh;
int mm;
int Time;
}player[150]; bool cmpTime( Player& a, Player& b) {
if(a.Time == b.Time)
return strcmp(a.name, b.name) < 0;
return a.Time < b.Time;
} int main() {
int casee = 1;
while(~scanf("%d", &N)) { if(!N) break;
if(casee!=1)
printf("\n");
printf("Case #%d\n", casee ++); for(int i = 1; i <= N; i ++) {
scanf("%s %d:%d", player[i].name, &player[i].hh, &player[i].mm);
player[i].Time = player[i].hh * 60 + player[i].mm;
} sort(player + 1, player + 1 + N, cmpTime); int num = 1; for(int i = 1; i <= N; i ++) {
printf("%s ", player[i].name);
if(player[i].Time == player[i - 1].Time)
printf("%d\n", num);
else {
num = i;
printf("%d\n", num);
}
}
}
return 0;
}

  

HDU 2115 I Love This Game的更多相关文章

  1. HDOJ(HDU) 2115 I Love This Game(排序排序、、、)

    Problem Description Do you like playing basketball ? If you are , you may know the NBA Skills Challe ...

  2. -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】

    [把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...

  3. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  4. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  5. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  6. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  7. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  8. hdu 2117:Just a Numble(水题,模拟除法运算)

    Just a Numble Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  9. HDU——2119 Matrix

    Matrix Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

随机推荐

  1. Hive(8)-常用查询函数

    一. 空字段赋值 1. 函数说明 NVL:给值为NULL的数据赋值,它的格式是NVL( value,default_value).它的功能是如果value为NULL,则NVL函数返回default_v ...

  2. 嵌入式GPIO接口及操作(二)

    目标:C语言实现点亮LED灯 首先是main函数,并不特殊,它是被系统调用来执行的,main函数结束后要返回调用main函数的地址处,那么裸机程序,没有操作系统做这些工作,就要自己写调用main函数的 ...

  3. linux signal函数遇到的问题

    1.关于signal函数的定义 signal最开始的原型是这: void (*signal(int signo, void (*func)(int)))(int);看过下面两行,了解到上面这一行是这个 ...

  4. 北京Uber优步司机奖励政策(2月17日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  5. kalibr论文阅读笔记

    单目相机IMU标定 该论文将相机IMU标定分为两个大方面: 一. 使用基函数来估计时间偏差 二. 相机和IMU的空间位置转换 校准变量:重力.外参旋转和平移.时钟偏移.IMU位姿.加速度计偏置.陀螺仪 ...

  6. Ubuntu 14.04 登录 界面添加 root账号

    1打开终端输入:sudo gedit /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf 2在弹出的编辑框里加入:greeter-show-manual- ...

  7. 「题目代码」P1054~P1059(Java)

    P1054 猴子吃桃 import java.util.*; import java.io.*; import java.math.BigInteger; import java.lang.Chara ...

  8. uvaoj1586Molar mass(暴力)

    An organic compound is any member of a large class of chemicalcompounds whose molecules contain carb ...

  9. Jmeter断言、参数化及集合点

    JMeter---QPS(Query Per Second) QPS为每秒查询率.是一台查询服务器每秒能够处理的查询次数,在因特网上,作为域名系统服务器的性能经常用每秒查询率来衡量.步骤:1.添加线程 ...

  10. 【JAVA】关于java中 类.class.getResource("/").getPath()获取路径有空格的问题

    写了一个web工程,在本地测试正确,但是部署到服务器上就出现错误.原因是读取不到配置文件. 后来从打印出来的文件路径中发现是用Java的class.getResource("/") ...