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. angular2配置使用ng2-bootstrap

    第一步,安装.进入项目目录 npm install ng2-bootstrap bootstrap --save 第二步,angular-cli 配置 ng2-bootstrap   src/.ang ...

  2. java的值传递机制

    一.练习:编写Java程序,将二维数组中的行列互调显示出来. 代码1为自己编写: package com.xxgpra.CH6; public class Hangliehudiao_pra4 { p ...

  3. C语言跳水比赛预测结果

    5位运动员参加了10米台跳水比赛,有人让他们预测比赛结果A选手说:B第二,我第三:B选手说:我第二,E第四:C选手说:我第一,D第二:D选手说:C最后,我第三:E选手说:我第四,A第一:比赛结束后,每 ...

  4. Go 入门 - 方法和接口

    方法和接口 方法的接受者 Go中没有类,取而代之的是在结构体上定义的方法 为了将方法(函数)绑定在某一类结构体上,我们在定义函数(方法)时引入"接受者"的概念. 方法接受者在它自己 ...

  5. BZOJ1083_繁忙的都市_KEY

    题目传送门 裸的最小生成树. code: /************************************************************** Problem: 1083 U ...

  6. MySql 增加字段 删除字段 修改字段名称 修改字段类型

    //1.增加一个字段 alter table user add COLUMN new1 VARCHAR(20) DEFAULT NULL; //增加一个字段,默认为空 alter table user ...

  7. WEB安全基础之sql注入基础

    1.基础sql语句 注释 单行注释# %23--+ --加空格多行注释/**/ SELECT(VERSION()) SELECT(USER()) SELECT(database()) 查数据库 SEL ...

  8. Navicat 导入sql脚本文件

    Navicat 导入sql脚本文件 我在组建自己工作用的数据库时要导入.sql脚本文件,用cmd窗口导入太慢,navicat的导入向导里又无导入sql脚本的选项, 但不是navicat中没有导入sql ...

  9. 前后端分离.net core + vuejs + element

    查找一些资料,比较了elementui以及Iview,最终还是选择了elementui搭建前后端分离框架,废话少说了,开始搭建环境: 1.基础软件环境 vue开发环境安装: ①nodejs (我安装的 ...

  10. Matlab R2016a 破解教程

    郑重声明:图片来源于网络,在这里感谢图片提供者,我写这篇教程,是希望帮助后来者少走弯路,而且,这是一种比较简单有效的破解方法,针对网上那种修改本地文件的方法,在这里不做介绍,如果想体验,可自己百度或谷 ...