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 获取时间后--自定义时间格式
自定义时间格式 =================================-===================================== #include <stdio.h ...
- ### mysql系统结构_3_Mysql_Learning_Notes
mysql系统结构_3_Mysql_Learning_Notes 存储层,内存结构 全局(buferpool) 只分配一次 全局共享 连接/会话(session) 针对每个会话/线程分配 按需动态分配 ...
- C# 各种类型的转换
/// <summary> /// 一些常用的方法 /// 1.一些高效的转换方法 /// </summary> public class Util { #region Obj ...
- 01 Go 1.1 Release Notes
Go 1.1 Release Notes Introduction to Go 1.1 Changes to the language Integer division by zero Surroga ...
- linux安装python3(已有python2.x情况下)
参考:https://www.cnblogs.com/Guido-admirers/p/6259410.html 1.官网下载python3 cd /home/download wget https: ...
- 密码记录工具keepass保存密码
https://www.cnblogs.com/wicub/p/5753005.html
- Linux sudo 配置
1.配置sudo权限 sudo配置信息保存在 /etc/sudoers 文件中,可以使用vi修改.但使用vi修改需要给root用户设置权限,可以使用 visudo 直接修改. visudo 复制这行将 ...
- ubuntu 创建容器 并ssh 连接容器
1.下载镜像:docker search ubuntu docker pull ubuntu 2. 创建容器 docker run --name spider_frame -p 8888:8888 - ...
- wpf 查找 子元素
RightContainer.ApplyTemplate();//如果找不到,就执行该句试一试 var xxx=UIHelper.FindChild<ScrollViewer>(Right ...
- 20165203 2017-2018-2 《Java程序设计》第一周学习总结
20165203 2017-2018-2<Java程序设计>第一周学习总结 教材学习内容总结 (一)Java的地位 Java是面向对象编程,并涉及网络.多线程等重要的基础知识,是一门很好的 ...