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 ...
随机推荐
- js种的循环语句
//js种的循环语句 //while与do while的区别是while是满足条件后才执行 //do while是不管满不满足条件都会执行一次 //for 循环与while,do while相比循环结 ...
- Linux下的多进程编程
1.进程 1.1进程的定义 <计算机操作系统>这门课对进程有这样的描述:进程(Process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统 ...
- 跨域请求之JSONP 三
script请求返回JSON实际上是脚本注入.它虽然解决了跨域问题,但它不是万能的. 不能接受HTTP状态码 不能使用POST提交(默认GET) 不能发送和接受HTTP头 不能设置同步调用(默认异步) ...
- nice和taskset命令
taskset -c 9,10 bash domain_analysis.sh && /home/work/odp/php/bin/php hourly_localdns_hijack ...
- HttpClient——连接关闭
HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("http://www.apache.org& ...
- Javascript 常用系统内置函数
1:在数组指定位置插入元素 array.splice(2, 0, "three"); //在索引2的位置,删除0个元素后,插入元素“three” 例子: // 原来的数组 va ...
- Cadence仿真利器,Cadence SI / PI Analysis – Sigrity安装及破解指南
Sigrity提供了丰富的千兆比特信号与电源网络分析技术,包括面向系统.印刷电路板(PCB)和IC封装设计的独特的考虑电源影响的信号完整性分析功能. Sigrity分析技术与Cadence Alleg ...
- libharu 源码编译 VS2010
最近项目中接过了一个libharu PDF 开源库的锅,哈哈.于是就自己编译了一套libharu 的MFC下的静态库和动态库. 编译libharu需要用到zlib库和libpng库,libpng库又依 ...
- MySQL 5.7.9 免安装配置
MySQL 5.7.9 免安装配置 环境:win10 64位 mysql版本:mysql-5.7.9-winx64.zip (http://dev.mysql.com/downloads/mysql/ ...
- 使用nodejs引用socket.io做聊天室
Server: var app = require('http').createServer(handler) , io = require('socket.io').listen(app) , fs ...