hdoj 5199 Gunner map
Gunner
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5199
Description
Jack will shot many times, he wants to know how many birds fall during each shot.
a bullet can hit many birds, as long as they stand on the top of the tree with height of H.
Input
In the second line, there are n numbers h[1],h[2],h[3],…,h[n] which describes the height of the trees.
In the third line, there are m numbers q[1],q[2],q[3],…,q[m] which describes the height of the Jack’s shots.
Please process to the end of file.
[Technical Specification]
1≤n,m≤1000000(106)
1≤h[i],q[i]≤1000000000(109)
All inputs are integers.
Output
Sample Input
4 3 1 2 3 4 1 1 4
Sample Output
HINT
题意
给你n个数m次询问,问你大小为A的数有多少个,第二次问的时候,就直接输出0就好
题解:
map可过,非常轻松(雾
~\(≧▽≦)/~啦啦啦
代码:
#include<cstdio>
#include<map>
using namespace std;
map<int,int> g;
int n,m;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
g.clear();
for(int i=;i<n;i++)
{
int x=read();
g[x]++;
}
for(int i=;i<m;i++)
{
int x=read();
if(g.find(x)==g.end())
{
printf("0\n");
}
else
{
printf("%d\n",g[x]);
g[x]=;
}
}
}
}
hdoj 5199 Gunner map的更多相关文章
- hdu 5199 Gunner(STL之map,水)
Problem Description Long long ago, there is a gunner whose name is Jack. He likes to go hunting very ...
- hdu 5199 Gunner
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5199 简单题,stl水之... #include<algorithm> #include& ...
- 二分查找 BestCoder Round #36 ($) Gunner
题目传送门 /* 题意:问值为x的个数有几个,第二次查询就是0 lower/upper_bound ()函数的使用,map也可过,hash方法不会 */ #include <cstdio> ...
- 二分查找 BestCoder Round #42 1002 Gunner II
题目传送门 /* 题意:查询x的id,每次前排的树倒下 使用lower_bound ()查找高度,f[i]记录第一棵高度为x树的位置,查询后+1(因为有序) */ #include <cstdi ...
- Gunner II(二分,map,数字转化)
Gunner II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...
- HDOJ.1800 Flying to the Mars(贪心+map)
Flying to the Mars 点我挑战题目 题意分析 有n个人,每个人都有一定的等级,高等级的人可以教低等级的人骑扫帚,并且他们可以共用一个扫帚,问至少需要几个扫帚. 这道题与最少拦截系统有异 ...
- HDOJ.1113 Word Amalgamation(map)
Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...
- HDOJ.1228 A + B (map)
A + B 点我挑战题目 点我一起学习STL-MAP 题意分析 讲字符串和数字用map对应即可 代码总览 /* Title:HDOJ.1228 Author:pengwill Date:2016-11 ...
- HDOJ.2072 单词数(map)
单词数 点我挑战题目 点我一起学习STL-MAP 题意分析 给出一行单词,判断这行有不同种的单词多少个,用map可以轻松解决. 代码总览 /* Title:HDOJ.2072 Author:pengw ...
随机推荐
- 谈谈Linux内核驱动的coding style【转】
转自:http://www.cnblogs.com/wwang/archive/2011/02/24/1960283.html 最近在向Linux内核提交一些驱动程序,在提交的过程中,发现自己的代码离 ...
- 音频增益响度分析 ReplayGain 附完整C代码示例【转】
转自:http://www.cnblogs.com/cpuimage/p/8846951.html 人们所熟知的图像方面的3A算法有: AF自动对焦(Automatic Focus)自动对焦即调节摄像 ...
- java基础17 模板模式
1.模版模式 解决某类事物的步骤有些是固定的,有些会发生改变的,那么这个时候我们可以为这一类事物提供一个模版代码,从而提高效率. 2.模版模式的步骤 1.先写出解决该类事物的其中一种解决方案; ...
- Robot Framework测试框架用例脚本设计方法
Robot Framework介绍 Robot Framework是一个通用的关键字驱动自动化测试框架.测试用例以HTML,纯文本或TSV(制表符分隔的一系列值)文件存储.通过测试库中实现的关键字驱动 ...
- vi/vim基本使用方法(转)
转自:http://www.cnblogs.com/itech/archive/2009/04/17/1438439.html vi/vim 基本使用方法 本文介绍了vi (vim)的基本使用方法,但 ...
- js中的异步[Important]
js作为前端最主流的语言,主要处理页面显示变化(mutation)和异步(asynchronicity), js语言的基本要素和使用惯例的演化大都围绕着这两大主题,两者均值得总结和思考的主题, 这里先 ...
- 一步一步学习IdentityServer3 (14) 启用Https
申领一个CA证书,我用了一个腾讯的免费证书night-c.cn,这是腾讯云买域名送的一个证书 是单域名,非泛域名 1:安装证书 IIS选择证书 2:将证书加载到Identityserver3中,并启 ...
- Hive(七)Hive分析窗口函数
一数据准备 cookie1,2015-04-10,1 cookie1,2015-04-11,5 cookie1,2015-04-12,7 cookie1,2015-04-13,3 cookie1,20 ...
- 【LOJ】#2072. 「JSOI2016」独特的树叶
题解 干脆题解套题解好了 毕竟我的hash方法是抄小迪的 https://www.cnblogs.com/RabbitHu/p/9165770.html 小迪太巨了%%% 之前模数是八位的WA了几个点 ...
- ubuntu16.04编译安装mysql5.7
1.安装编译依赖 sudo apt-get install make cmake gcc g++ bison libncurses5-dev build-essential 2.下载mysql5.7源 ...