题目连接

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的更多相关文章

  1. HDU 1718 Rank counting sort解法

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

  2. HDOJ(HDU) 1718 Rank(水题、、、)

    Problem Description Jackson wants to know his rank in the class. The professor has posted a list of ...

  3. HDU 1718 Rank (排序)

    题意:给你n个学号和成绩,并且给定一个学号,让找这个学号是多少名. 析:用个结构体,按成绩排序,然后找那个学号,这个题有一个小坑,那就是并列的情况, 可能并列多少名,这个要考虑一下,其他的easy! ...

  4. HDU 1718 Rank 排序

    解题报告:给一个班的学生的分数排序,然后判断Jack在他们班级的排名是多少,并且有如下规定,若多个人的分数相同,则他们的排名也 是相同的.说白了就是问这个班上分数比Jack高的人数有多少个,如果有n个 ...

  5. ACM: hdu 1811 Rank of Tetris - 拓扑排序-并查集-离线

    hdu 1811 Rank of Tetris Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & % ...

  6. hdu 1704 Rank (floyd闭包)

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

  7. hdu 1811 Rank of Tetris - 拓扑排序 - 并查集

    自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球. 为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜, ...

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

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

  9. HDU 1704 Rank

    Rank Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 17046 ...

随机推荐

  1. 压缩上传并预览 flash

    最近研究一个功能:用as3写的上传图片并实现预览.觉得花了很多时间也学到很多知识,将自己的所得记录下来供大家分享. 首先是预览功能的实现,大家自然而然就想到了loader来加载图片并显示,由于项目没有 ...

  2. Django中级篇(下)

    中间件 django 中的中间件(middleware),在django中,中间件其实就是一个类,在请求到来和结束后,django会根据自己的规则在合适的时机执行中间件中相应的方法. MIDDLEWA ...

  3. TRMM数据的读取

    编辑下头文件,就有投影信息,然后再转换成你需要的投影方式1) From the command line, type in, ENVI, 2) Click File|Open External Fil ...

  4. Windows phone 8 学习笔记(5) 图块与通知(转)

    基于metro风格的Windows phone 8 应用提到了图块的概念,它就是指启动菜单中的快速启动图标.一般一个应用必须有一个默认图块,还可以有若干个次要图块.另外,通知与图块的关系比较密切,我们 ...

  5. CSS 3 中二维三维以及渐变过程简单总结 及效果(动图不好发)

    一. 不动,区域内的变化(本质生产一张图片) /*渐变                 1  长方形之渐变先定义长方形的宽高大小(好观察最好加边框)                           ...

  6. 测试一个C段网络的联通性

    #!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATHnetwork ...

  7. Oracle中存储过程与函数的区别

    Oracle 获取信息一般用function 修改数据用存储过程(需要执行commit命令)

  8. iOS中UIKit——UIButton设置边框

    UIButton *testButton = [UIButton buttonWithType:UIButtonTypeSystem]; [testButton setFrame:CGRectMake ...

  9. PeopleSoft Object Types Definitions

     PeopleSoft stores object definitions types such as Record, Field and SQL definitions as numbers in  ...

  10. 通过 XML HTTP 加载 XML 文件

    新建一个.aspx文件 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="02-通 ...