题目连接

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大法好。。

 1 #include<algorithm>
 2 #include<iostream>
 3 #include<cstdlib>
 4 #include<cstring>
 5 #include<cstdio>
 6 #include<map>
 7 using std::map;
 8 map<int, int> rec;
 9 int main() {
10 #ifdef LOCAL
11     freopen("in.txt", "r", stdin);
12     freopen("out.txt", "w+", stdout);
13 #endif
14     int num, id, score, rank, targe;
15     while (~scanf("%d", &num)) {
16         rank = 0, rec.clear();
17         while (~scanf("%d %d", &id, &score) && id + score) rec[id] = score;
18         targe = rec[num];
19         map<int, int>::iterator ite;
20         for (ite = rec.begin(); ite != rec.end(); ++ite) {
21             if (ite->second > targe) rank++;
22         }
23         printf("%d\n", rank + 1);
24     }
25     return 0;
26 }

View Code

转载于:https://www.cnblogs.com/GadyPu/p/4563512.html

hdu 1718 Rank相关推荐

  1. HDU 1718 Rank counting sort解法

    本题是利用counting sort的思想去解题. 注意本题,好像利用直接排序,然后查找rank是会直接被判WA的.奇怪的推断系统. 由于分数值的范围是0到100,很小,而student 号码又很大, ...

  2. (HDU)1718 -- Rank (段位)

    题目链接:https://vjudge.net/problem/HDU-1718 这题还好,不用考虑字典序排名(可以并列排名),看到有的人用了结构体或二重数组,介于这题的特殊性,其实不用这样. #in ...

  3. HDU 1811 Rank of Tetris(并查集按秩合并+拓扑排序)

    Rank of Tetris Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  4. HDU 2643 Rank:第二类Stirling数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2643 题意: 有n个个选手参赛,问排名有多少种情况(可以并列). 题解: 简化问题: 将n个不同的元素 ...

  5. HDU 1811 Rank of Tetris

    Rank of Tetris Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...

  6. hdu 1811 Rank of Tetris (并查集+拓扑排序)

    Problem - 1811 感觉这题的并查集以及拓扑排序并不难,但是做题的时候必须理解到矛盾(CONFLICT)与不确定(UNCERTAIN)直接的优先关系. 做这题的时候,构图什么的很简单,就是没 ...

  7. HDU - 1811 Rank of Tetris 并查集 + 拓扑序 +me

    link 题意: 首先看到排名自然想到拓扑序,但是存在等于的情况,这就启发我们把等于的情况缩成一个点,让后在缩点后的图中进行拓扑即可. 对于不合法的情况当然是拓扑序没有遍历到应该遍历的点,所以只需要检 ...

  8. HDU -1704 Rank——floyd

  9. 信奥中的数学:斯特林数、卡特兰数

    P1287 盒子与球(球不同 盒不同 不允许有空盒) 盒子与球 - 洛谷 第二类斯特林数总结 第二类斯特林数总结 - _zjz 的博客 - 洛谷博客 P4091 [HEOI2016/TJOI2016] ...

最新文章

  1. 必读干货 | 如何做好向上管理,分享我实践多年的完整方法论
  2. Azure VNet介绍
  3. 微信小程序点击按钮弹出弹窗_微信小程序实现的点击按钮 弹出底部上拉菜单功能示例...
  4. 深圳市南山区学计算机的视频课程,新手学电脑全套视频教程(1-27集)
  5. endnote如何添加网页类参考文献
  6. VScode配置CMD本地运行环境(2.0)
  7. android中webview空间通过Img 标签显示sd卡中 的图片
  8. java utility工具类怎么导入_Utility.java
  9. C艹入门 -> 入土
  10. 石家庄地铁路线安排网站的最终版本——博客登记
  11. 传统计算机硬盘和固态硬盘有哪些区别,工业级固态硬盘与传统硬盘有什么区别...
  12. 公司电脑监控软件究竟有何作用?
  13. itss认证条件是什么?
  14. 电机控制编程的数学运算优化方案
  15. svn项目迁移后服务器up报错:E155036 的处理方法
  16. 疫情下的长租公寓:蛋壳们的“生死考”
  17. 红米note5软件打开速度测试,差一点才完美!红米Note5深度评测(骁龙636性能测试)...
  18. Mybatis开启一级、二级缓存
  19. linux如何安装vmtools工具
  20. 如何搭建自己的微信公众号服务

热门文章

  1. eclipse 使用svn导入web项目
  2. python open 函数漏洞_Python系列之——编写已知漏洞exp实现批量getshell
  3. MapReduce框架下的FP Growth算法概述
  4. 聚类分析应用之市场细分
  5. Android NDK开发之 arm_neon.h文件ABI说明
  6. 数学连乘和累加运算符号_2020中考数学 初中数学有理数计算(干货)
  7. Git——添加文件【git add / git commit】
  8. [W:pyppeteer.chromium_downloader] start chromium download
  9. String s = new String(“xyz“);创建了几个字符串对象?
  10. PAT (Basic Level) Practice1024 科学计数法