题目链接:http://poj.org/problem?id=2153

思路分析:

判断Li Ming的成绩排名,需要在所有的数据章查找成绩比其高的人的数目,为查找问题。

查找问题可以使用Hash表,STL中的Map,查找树,或者使用排序与二分查找即可。

代码:

#include <iostream>
#include <map>
#include <string>
using namespace std; int main()
{
int personNum, examTimes, scoreOfLi;
string stuName;
map<string, int> rankList; cin >> personNum;
cin.get( );
for (int i = ; i < personNum; ++i)
{
getline(cin, stuName);
rankList[stuName] = ;
}
cin >> examTimes;
cin.get( );
for (int i = ; i < examTimes; ++ i)
{
int score; for (int j = ; j < personNum; ++ j)
{
cin >> score;
cin.get( );
getline(cin, stuName);
rankList[stuName] += score;
if (stuName == string("Li Ming"))
scoreOfLi = rankList[stuName];
} int rankOfLiMing = ;
for (map<string, int>::iterator iter = rankList.begin( ); iter != rankList.end(); ++iter)
{
if (iter->second > scoreOfLi)
rankOfLiMing++;
}
cout << rankOfLiMing << endl;
} return ;
}

poj 2153 Rank List(查找,Map)的更多相关文章

  1. POJ 2153 Rank List (map映射)

    水题,竟然花了那么多时间...主要是不知道为什么,明明在本机上编译过去了,但是用c++提交却编译错误...最后用g++提交AC 题意:给出n个学生的名字,然后给出m个测验. 每个测验给出n个学生的分数 ...

  2. poj 2153 Rank List

    原题链接:http://poj.org/problem?id=2153 简单题,map,平衡树均可.. map: #include<algorithm> #include<iostr ...

  3. poj 2503 Babelfish (查找 map)

    题目:http://poj.org/problem?id=2503 不知道为什么 poj  的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostrea ...

  4. 成绩累加排名,poj(2153)

    题目链接:http://poj.org/problem?id=2153 解题报告: 注意map中的string,因此要将char[]转换为string型. #include <iostream& ...

  5. POJ 3096 Surprising Strings(STL map string set vector)

    题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...

  6. poj 3087 Shuffle'm Up ( map 模拟 )

    题目:http://poj.org/problem?id=3087 题意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块牌归为s ...

  7. POJ 2503 单词映射(map)

    Sample Input dog ogdaycat atcaypig igpayfroot ootfrayloops oopslay atcayittenkayoopslaySample Output ...

  8. poj 2452(RMQ+二分查找)

    题目链接: http://poj.org/problem?id=2452 题意:在区间[1,n]上找到满足 a[i]<a[k]<a[j] (i<=k<=j) 的最大子区间 (j ...

  9. HDOJ1251(前缀匹配---分块查找&map应用)

    分块查找算法 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm ...

随机推荐

  1. socket中的option

    /// Set an option on the socket. /** * This function is used to set an option on the socket. * * @pa ...

  2. AutoCompleteTextView 自动提示

    在输入框中输入我们想要输入的信息就会出现其他与其相关的提示信息,这种效果在Android中是用AutoCompleteTextView实现的. public class MainActivity ex ...

  3. 美化 input type=file控件

    大家都知道input的type=file控件默认样式是不能修改的 可以通过一个小技巧处理下 html: <a href="javascript:;" class=" ...

  4. Python: how to public a model

    1, Create a folder fileFolder 2, create a file tester.py 3, create another file setup.py: The conten ...

  5. .NET 条件查询实现--类似网上商城宝贝搜索

    需要实现的效果:点击表格列头:弹出一个层,用户可以输入当前列头的查询条件,点击确定之后,把该列头的查询信息显示在页面顶部,用户可以叉掉这个查询条件,恢复到查询之前的数据. 大致实现的效果图: 项目背景 ...

  6. oracle查询字符集语句

      (1)查看字符集(三条都是等价的) 复制代码 代码如下: select * from v$nls_parameters  where parameter='NLS_CHARACTERSET'sel ...

  7. PCB板常用知识简介——沉金板VS镀金板

    一.PCB板表面处理:  抗氧化,喷锡,无铅喷锡,沉金,沉锡,沉银,镀硬金,全板镀金,金手指,镍钯金 OSP: 成本较底,可焊性好,存储条件苛刻,时间短,环保工艺.焊接好 .平整 . 喷锡:喷锡板一般 ...

  8. Java泛型的一点用法(转)

    1.一个优秀的泛型,建议不要这样写public static <K, V> Map<K, V> getMap(String source, String firstSplit, ...

  9. iOS中菊花。。。

    其实系统的菊花除了功能有点单一,不具有刷新页面的功能以外,其他都还好吧,满足你一些正常的提示功能还是绰绰有余的:直接把项目里面的代码粘出来吧,其实也没有什么特别要注意的地方,一些设置属性也算留个备份 ...

  10. SSD磁盘,CPU居高不下,高并发的情况下,是不是mysql解析器耗费的cpu资源高?

    你看看我做的实验,这个user表是300多W纪录,普通磁盘下,消耗时间最多的是Copy to tmp table 0.81秒,当然在ssd下,这个可以减少很多很多的,第二高就是sending data ...