hdu 1718 Rank
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=1718
Rank
Description
Jackson wants to know his rank in the class. The professor has posted a list of student numbers and marks. Compute Jackson’s rank in class; that is, if he has the top mark(or is tied for the top mark) his rank is 1; if he has the second best mark(or is tied) his rank is 2, and so on.
Input
The input consist of several test cases. Each case begins with the student number of Jackson, an integer between 10000000 and 99999999. Following the student number are several lines, each containing a student number between 10000000 and 99999999 and a mark between 0 and 100. A line with a student number and mark of 0 terminates each test case. There are no more than 1000 students in the class, and each has a unique student number.
Output
For each test case, output a line giving Jackson’s rank in the class.
Sample Input
20070101
20070102 100
20070101 33
20070103 22
20070106 33
0 0
Sample Output
2
stl大法好。。
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<map>
using std::map;
map<int, int> rec;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int num, id, score, rank, targe;
while (~scanf("%d", &num)) {
rank = , rec.clear();
while (~scanf("%d %d", &id, &score) && id + score) rec[id] = score;
targe = rec[num];
map<int, int>::iterator ite;
for (ite = rec.begin(); ite != rec.end(); ++ite) {
if (ite->second > targe) rank++;
}
printf("%d\n", rank + );
}
return ;
}
hdu 1718 Rank的更多相关文章
- HDU 1718 Rank counting sort解法
本题是利用counting sort的思想去解题. 注意本题,好像利用直接排序,然后查找rank是会直接被判WA的.奇怪的推断系统. 由于分数值的范围是0到100,很小,而student 号码又很大, ...
- HDOJ(HDU) 1718 Rank(水题、、、)
Problem Description Jackson wants to know his rank in the class. The professor has posted a list of ...
- HDU 1718 Rank (排序)
题意:给你n个学号和成绩,并且给定一个学号,让找这个学号是多少名. 析:用个结构体,按成绩排序,然后找那个学号,这个题有一个小坑,那就是并列的情况, 可能并列多少名,这个要考虑一下,其他的easy! ...
- HDU 1718 Rank 排序
解题报告:给一个班的学生的分数排序,然后判断Jack在他们班级的排名是多少,并且有如下规定,若多个人的分数相同,则他们的排名也 是相同的.说白了就是问这个班上分数比Jack高的人数有多少个,如果有n个 ...
- ACM: hdu 1811 Rank of Tetris - 拓扑排序-并查集-离线
hdu 1811 Rank of Tetris Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & % ...
- hdu 1704 Rank (floyd闭包)
Rank Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- hdu 1811 Rank of Tetris - 拓扑排序 - 并查集
自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球. 为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜, ...
- HDU 1811 Rank of Tetris(并查集按秩合并+拓扑排序)
Rank of Tetris Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- HDU 1704 Rank
Rank Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 17046 ...
随机推荐
- c# 获取excel所有工作表
var filePath="f:\xx.xlsx" string connStr = "Provider=Microsoft.Ace.OleDb.12.0;" ...
- php头函数和浏览器缓存
可以通过php头函数改变返回给浏览器的头信息 例: 代码中添加头: header("Cache-Control: max-age=31536000"); header(" ...
- idea 下的maven使用问题汇总
1,-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable ...
- windows对象分类
用户对象 GDI对象 内核对象 如何判断一个对象是不是内核对象 看创建函数,几乎所有的内核对象创建函数都会有PSECURITY_ATTRIBUTES参数
- (笔记)angular material radio用法
- HttpClient——连接关闭
HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("http://www.apache.org& ...
- 一分钟学会(一):.NET之正则表达式
本文介绍正则表达式在.NET中的基本应用,代码简单粗暴,实例浅显易懂,让你一分钟快速上手正则(大鸟请略过). 本文为入门文章,很多时候我们只是忘记了语法,这也可作为一个快速查询的参考. 如果想深入学习 ...
- c++库大全
1.C++各大有名库的介绍——C++标准库 2.C++各大有名库的介绍——准标准库Boost 3.C++各大有名库的介绍——GUI 4.C++各大有名库的介绍——网络通信 5.C++各大有名库的介绍— ...
- 很不错的安卓FadingActionBar控件源码
这个我刚刚从一个github下载过来的,自己测试一下运行了,感觉还不错的,安卓FadingActionBar控件源码,现在就给大家分享一下,源码我已经上传到源码天堂那里了,想下载的朋友可以去那里下载吧 ...
- .net4.0注册到IIS
IIS和.netfw4.0安装顺序是从前到后,如果不小心颠倒了,无所谓. 打开程序-运行-cmd:输入一下命令重新注册IIS C:\WINDOWS\Microsoft.NET\Framework\v4 ...