题目链接: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. shell检测interface是否已分配ip,qt调用shell脚本

    #include <QCoreApplication>#include <QDebug>#include <QTextStream>#include <QDi ...

  2. lab4 Cache Geometries 深入理解计算机系统——高速缓存

    这个实验主要是将高速缓存命中的一点东西,意在告诉我们平常多注意这方面的东西. 不懂java的,所以只管C的部分. You will do this several times, making smal ...

  3. Servlet基础知识(一)——Servlet的本质

    什么是Servlet: Servlet是运行在web服务器端(web容器,如tomcat)的程序,它与Applet相对,Applet是运行在客户端的程序. Servlet的主要作用是处理客户端的请求, ...

  4. JQuery的Select操作集合

    jQuery获取Select选择的Text和Value:   语法解释: $("#select_id").change(function(){//code...}); //为Sel ...

  5. poj 3252 Round Numbers 数位dp

    题目链接 找一个范围内二进制中0的个数大于等于1的个数的数的数量.基础的数位dp #include<bits/stdc++.h> using namespace std; #define ...

  6. valgrind用于检测内存泄露

    http://www.thegeekstuff.com/2011/11/valgrind-memcheck/

  7. Groovy中那些神奇注解之ToString

    继续上一篇:Groovy中那些神奇注解之Memoized 这篇就讲讲@groovy.transform.ToString这个注解,这注解太熟悉了,熟悉到让人一看就知道是干吗的,不就是把Bean转在St ...

  8. 去掉Flex4生成的SWF加载时的进度条

    原文 http://www.cnblogs.com/modou/articles/1955507.html 方法一: <?xml version="1.0" encoding ...

  9. BZOJ 4518 [Sdoi2016]征途(分治DP)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4518 [题目大意] 给出一个数列,分成m段,求方差最小,答案乘上m的平方. [题解] ...

  10. cpu亲和力总结taskset和setcpu及其他相关

    一:taskset -- 获取或指定进程运行的CPU. man taskset出现 CPU affinity is a scheduler property that "bonds" ...