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. reids同步机制和远程连接

    RDB同步机制: 开启和关闭:默认情况下是开启了.如果想关闭,那么注释掉redis.conf文件中的所有save选项就可以了. 同步机制: save 900 1:如果在900s以内发生了1次数据更新操 ...

  2. go学习笔记-反射(Reflection)

    反射(Reflection) 反射是利用reflect包实现的 反射可大大提高程序的灵活性,使得interface{}有更大的发挥余地 反射使用TypeOf和ValueOf函数从接口中获取目标对象信息 ...

  3. 数据结构之栈和队列及其Java实现

    栈和队列是数据结构中非常常见和基础的线性表,在某些场合栈和队列使用很多,因此本篇主要介绍栈和队列,并用Java实现基本的栈和队列,同时用栈和队列相互实现. 栈:栈是一种基于“后进先出”策略的线性表.在 ...

  4. 深入理解@RequestBody注解

    我写文章历来追求通俗易懂,今天来深入探讨一下@RequestBody注解.提起这个,所有做过mvc开发的同学应该都不陌生,使用上面肯定也是信手拈来. 所以我这里就简单的提一下这个注解的使用: 1.当客 ...

  5. vue中cssModules理解可以用于加密和避免重复使用

    cssModules可以用于加密和避免重复使用,也就是说可以在当前vue文件中写的样式会生成独一无二的名字,在其他vue文件中是无法调用的, 一.可以直接配cssModules 第一步,配置vue-l ...

  6. react前置路由守卫

    react中一切皆组件-- 目标:自定义user界面的前置路由守卫,当用户点击要进入user组件时,路由守卫发起判断,如果条件满足则进入,否则跳转至login组件. .入口文件index.js中代码如 ...

  7. mac, start sublime from terminal

    1.where is sublime CLI /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl 2. run sublime ...

  8. 在同一台机器上启动多个tomcat服务(转)

    转载:https://blog.csdn.net/wangxy799/article/details/53957770 1.案例:配置一台机上配置三个Tomcat 2.方法1:[只用修改第一个以外To ...

  9. 天津Uber优步司机奖励政策(1月4日~1月10日)

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

  10. FreeRTOS信号量的封装函数参数是二级指针

    1. 先看正确的封装方式,问题所在,为什么要用2级指针 void cissys_lockcreate(void** mutex) { //创建信号量,应该是互斥锁 *mutex = ((Semapho ...