Gunner

Time Limit: 1 Sec  Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5199

Description

Long long ago, there is a gunner whose name is Jack. He likes to go hunting very much. One day he go to the grove. There are n birds and n trees. The i−th bird stands on the top of the i−th tree. The trees stand in straight line from left to the right. Every tree has its height. Jack stands on the left side of the left most tree. When Jack shots a bullet in height H to the right, the bird which stands in the tree with height H will falls.
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

There are multiple test cases (about 5), every case gives n,m in the first line, n indicates there are n trees and n birds, m means Jack will shot m times.

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

For each q[i], output an integer in a single line indicates the number of birds Jack shot down.

Sample Input

4 3 1 2 3 4 1 1 4

Sample Output

1 0 1

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的更多相关文章

  1. hdu 5199 Gunner(STL之map,水)

    Problem Description Long long ago, there is a gunner whose name is Jack. He likes to go hunting very ...

  2. hdu 5199 Gunner

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5199 简单题,stl水之... #include<algorithm> #include& ...

  3. 二分查找 BestCoder Round #36 ($) Gunner

    题目传送门 /* 题意:问值为x的个数有几个,第二次查询就是0 lower/upper_bound ()函数的使用,map也可过,hash方法不会 */ #include <cstdio> ...

  4. 二分查找 BestCoder Round #42 1002 Gunner II

    题目传送门 /* 题意:查询x的id,每次前排的树倒下 使用lower_bound ()查找高度,f[i]记录第一棵高度为x树的位置,查询后+1(因为有序) */ #include <cstdi ...

  5. Gunner II(二分,map,数字转化)

    Gunner II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total ...

  6. HDOJ.1800 Flying to the Mars(贪心+map)

    Flying to the Mars 点我挑战题目 题意分析 有n个人,每个人都有一定的等级,高等级的人可以教低等级的人骑扫帚,并且他们可以共用一个扫帚,问至少需要几个扫帚. 这道题与最少拦截系统有异 ...

  7. HDOJ.1113 Word Amalgamation(map)

    Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...

  8. HDOJ.1228 A + B (map)

    A + B 点我挑战题目 点我一起学习STL-MAP 题意分析 讲字符串和数字用map对应即可 代码总览 /* Title:HDOJ.1228 Author:pengwill Date:2016-11 ...

  9. HDOJ.2072 单词数(map)

    单词数 点我挑战题目 点我一起学习STL-MAP 题意分析 给出一行单词,判断这行有不同种的单词多少个,用map可以轻松解决. 代码总览 /* Title:HDOJ.2072 Author:pengw ...

随机推荐

  1. iframe 同域下父子页面的通信

    //共同引用的JS文件 common.js ; (function (window, $) { $(function ($) { window.trip = window.trip || {}; wi ...

  2. 谈谈.NET MVC QMVC高级开发

    自从吾修主页上发布了QMVC1.0,非常感兴趣,用了半月的时间学习,真的感觉收益非浅,在此声明非常感谢吾修大哥的分享! 1.轻快简单,框架就几个类,简单,当然代码少也就运行快!单纯的MVC,使的如果你 ...

  3. 自定义ProgressBar的加载效果

    三种方式实现自定义圆形页面加载中效果的进度条 To get a ProgressBar in the default theme that is to be used on white/light b ...

  4. 树莓派指定静态IP

    1.备份并清空 interfaces 文件 cp /etc/network/interfaces /etc/network/interfaces.bak vi /etc/network/interfa ...

  5. (转)链接服务器——获取EXCEL数据

    测试目的:验证利用链接服务器.分布式查询获取EXCEL中的数据测试环境:Microsoft SQL Server 2005 - 9.00.3080.00 (X64)  Enterprise Editi ...

  6. 安装SHARP MX-3618NC PCL6打印机驱动程序

    第一步,  打开MX-CR3_PCL_PS_1302a_ChineseS_Win8Server2012.exe 驱动程序 此驱动支持Win8.Server2012及以下版本的操作系统,同时兼容Win1 ...

  7. MySQL权限问题

    1.修改MySQL用户密码 .先来看一个PASSWORD()函数,MYSQL使用MD5加密 SELECT PASSWORD(‘root’); .使用mysql数据库,查看用户表 USE mysql; ...

  8. linux nc命令使用详解(转)

    linux nc命令使用详解 功能说明:功能强大的网络工具 语 法:nc [-hlnruz][-g<网关...>][-G<指向器数目>][-i<延迟秒数>][-o& ...

  9. day5模块学习--XML模块

    XML文件处理 XML文件处理,有好几种方式,这里介绍一下xml.etree.ElementTree as ET. 注意:xml.etree.ElementTree模块在应对恶意结构数据时显得并不安全 ...

  10. 【51nod】1564 区间的价值

    题解 这个要注意到一个长度大的区间的最大价值一定比长度小的区间的价值要大 然后我们以每个点为最小值,显然区间越长最大值越大,然后我们更新最大区间长度的取值,这个可以用单调栈求这个最小值能更新到的左右端 ...