题目链接: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. hive 学习笔记精简

    创建表: drop table t create table if not exists t (t string) partitioned by (log_date string) row forma ...

  2. spring schema自定义

    今天看了一下分布式服务框架的那本书,于是里面提到了spring schema的自定义,于是去简单的了解了一下 参考资源:spring schema扩展: http://www.yihaomen.com ...

  3. Exception in MessageQueue callback: handleReceiveCallback

    07-20 14:27:11.477: E/InputEventReceiver(7209): Exception dispatching input event. 07-20 14:27:11.47 ...

  4. URL伪静态设置 (apache2.4)

    ` ` 1.修改apche主配置文件 主要是 #LoadModule rewrite_module modules/mod_rewrite.so 改为 LoadModule rewrite_modul ...

  5. if最简单的用法

    /* Name:if最简单的用法-1 Copyright:By.不懂网络 Author: Yangbin Date:2014年2月9日 03:00:58 Description:if最简单的用法,真则 ...

  6. win7系统中桌面图标显示不正常问题

    http://jingyan.baidu.com/article/466506580c9327f549e5f8dc.html 最近笔者在安装软件时,突然出现了桌面图标显示不正常了,一开始还以为是新安装 ...

  7. Linux 组与用户

    组: 添加: groupadd groupName -g groupID  --> groupadd dba -g 502 删除: groupdel  groupName             ...

  8. 01-复杂度2. Maximum Subsequence Sum (25)

    Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, ...

  9. ural 1057(数位dp)

    数位dp题,关键是用树的思维去考虑. 对于一个数字X,要是能表示成K个B的不同次幂,等价于X在B进制下有且只有K个位上面的数字为一,其他位上的数字都为0. 具体读者可以去参考,国家集训队李聪的论文,里 ...

  10. Dropping Balls (二叉树+思维)

      Dropping Balls  A number of K balls are dropped one by one from the root of a fully binary tree st ...