poj 2153
题意:题目还是很简单的,就是求Li Ming 在班上的排名,而且成绩是相加的。
思路:用map就行。不然好像用qsort+二分也可以,不过我在那里碰到了一些状况,然后就没用这种方法了,简单的map就可以解决。
map是根据前面的类型来进行排序的,map是有序的。
Memory: 1220K Time: 1407MS
Language: C++ Result: Accepted
Source Code
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <map>
#include <string> using namespace std; int main()
{
int n,m,ans;
char s[100];
while(scanf("%d",&n)!=EOF)
{
getchar();
map<string,int>mp;
map<string,int>:: iterator it;
for(int i=0;i<n;i++)
{
gets(s);
mp[s]=0;
}
scanf("%d",&m);
for(int i=0;i<m;i++)
{
for(int j=0,tmp=0;j<n;j++)
{
scanf("%d",&tmp);
getchar();
gets(s);
mp[s]+=tmp;
}
ans=0;
for(it=mp.begin();it!=mp.end();it++)
if(it->second>mp["Li Ming"]) ans++;
printf("%d\n",ans+1);
}
}
return 0;
}
poj 2153的更多相关文章
- poj 2153 Rank List
原题链接:http://poj.org/problem?id=2153 简单题,map,平衡树均可.. map: #include<algorithm> #include<iostr ...
- poj 2153 Rank List(查找,Map)
题目链接:http://poj.org/problem?id=2153 思路分析: 判断Li Ming的成绩排名,需要在所有的数据章查找成绩比其高的人的数目,为查找问题. 查找问题可以使用Hash表, ...
- 成绩累加排名,poj(2153)
题目链接:http://poj.org/problem?id=2153 解题报告: 注意map中的string,因此要将char[]转换为string型. #include <iostream& ...
- POJ 2153 stl
#include<iostream> #include<map> #include<string> using namespace std; int main() ...
- POJ 2153 Rank List (map映射)
水题,竟然花了那么多时间...主要是不知道为什么,明明在本机上编译过去了,但是用c++提交却编译错误...最后用g++提交AC 题意:给出n个学生的名字,然后给出m个测验. 每个测验给出n个学生的分数 ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
随机推荐
- Linux python <tab>自动补全
为Python添加交互模式下TAB自动补全以及命令历史功能. 1.获取python目录 [root@localhost ~]# python Python 2.6.6 (r266:84292, Jul ...
- SICP— 第一章 构造过程抽象
SICP Structure And Interpretation Of Computer Programs 中文第2版 分两部分 S 和 I 第一章 构造过程抽象 1,程序设计的基本元素 2,过 ...
- js实现99乘法表
实现99乘法表(输出到页面上) * document.write("<table border='1' bordercolor='blue'>"); //循环行 9 f ...
- html、css杂记
1:浮动 <div style="float: left"> 2:清除浮动,把父div撑起来 <div style="clear:both"& ...
- Thinkphp 连接查询的使用
方法一:使用table()方法 $tables = 'b_order ordert, b_busbid busbid'; $map['busbid.buscompanyid'] = 1; $map[' ...
- margin-bottom在IE6和IE7下失效的解决办法
IE6/7下margin-bottom无效一般出现在容器里某元素设置后在父容器内无效,这个时候只需要在父容器中加入以下两句css,基本上所有的浏览器都兼容了: overflow:hidden;zoom ...
- vim 配置,我本机的配置[windows]
set nocompatible source $VIMRUNTIME/vimrc_example.vim source $VIMRUNTIME/mswin.vim behave mswin set ...
- Java字节流:InputStream OutputStream
字节输入流:InputStream 类声明: public abstract class InputStream implements Closeable 位于java.io包下,是一个抽象类. 官方 ...
- .net利用NPOI导入导出Excel
NPOI在.net中的操作Excel 1.读取 using (FileStream stream = new FileStream(@"c:\客户资料.xls", FileMode ...
- SRM 513 2 1000CutTheNumbers(状态压缩)
SRM 513 2 1000CutTheNumbers Problem Statement Manao has a board filled with digits represented as St ...