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=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;
}
int main()
{while(scanf("%d%d",&n,&m)!=EOF){g.clear();for(int i=0;i<n;i++){int x=read();g[x]++;}for(int i=0;i<m;i++){int x=read();if(g.find(x)==g.end()){printf("0\n");}else{printf("%d\n",g[x]);g[x]=0;}}}
}

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. 【map】【HDOJ】5233 Gunner II

    http://acm.hdu.edu.cn/showproblem.php?pid=5233 外面有很多树,每棵树顶上有一只鸟,一个数组按从近到远的顺序列出这些树的高度(也就是鸟的高度) 猎人开始从不 ...

  3. hdu 5199 map或二分或哈希

    题目描述:给出n棵树的高度,每棵树上都站着一只鸟,枪手Jack站在最左边那棵树的左边对鸟进行射击,当Jack在高度为H的地方向右发射一颗子弹的时候,高度为H的树上的鸟儿就会掉落(注:其他树上的鸟儿不会 ...

  4. HDOJ 1228 A+B(map水题)

    A + B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  5. Gunner(map)

    题目 题目大致翻译:很久以前,有一个枪手叫杰克.他非常喜欢去打猎.有一天他去了小树林.有n只鸟和n棵树.第i只鸟站在第i棵树的顶端.这些树从左到右成一条直线.每棵树都有它的高度.杰克站在最左边那棵树的 ...

  6. 【HDOJ】4343 Interval query

    最大不相交集合的数量. 思路是dp[i][j]表示已经有i个不相交集合下一个不相交集合的最右边界. 离散化后,通过贪心解. 1 /* 4343 */ 2 #include <iostream&g ...

  7. 【HDOJ】4579 Random Walk

    1. 题目描述 一个人沿着一条长度为n个链行走,给出了每秒钟由i到j的概率($i,j \in [1,n]$).求从1开始走到n个时间的期望. 2. 基本思路 显然是个DP.公式推导也相当容易.不妨设$ ...

  8. AC自动机 HDOJ 5384 Danganronpa

    题目传送门 1 /* 2 题意:多个文本串,多个模式串在每个文本串出现的次数 3 AC自动机:这就是一道模板题,杭电有道类似的题目 4 */ 5 /************************** ...

  9. 构造 HDOJ 5400 Arithmetic Sequence

    题目传送门 题意:问有多少个区间,其中存在j使得ai + d1 == ai+1(i<j) && ai + d2 == ai+1 (i>j) 构造:用c1[i], c2[i] ...

最新文章

  1. 无线网中的一些技术名词和解释
  2. Linux2.6 内核进程调度分析
  3. linux颜色吸取工具,8 个优秀的 Linux 图形图像及色彩工具
  4. java fx border_JavaFx UI控件与代码间的绑定方法
  5. linux mysql 定时任务_Linux下Mysql定时任务备份数据的实现方法
  6. 华为PLC-IoT生态联盟成立,携手合作伙伴共赢智慧物联新时代
  7. ios应用程序开发框架
  8. python入门第二十五天--反射 通过字符串的形式操作对象中的成员
  9. C语言 标准库stdio.h
  10. 使用片段嵌入进行文档搜索
  11. 浅谈数据挖掘与机器学习
  12. 玩转流量,天下无锅——IT运维人员的九阳神功(上)
  13. 如何成为一个精力充沛的程序员——掌控
  14. Oracle数据库表空间用户权限
  15. 山东计算机设计大赛,山东大学控制学院本科生获中国大学生计算机设计大赛国家级二等奖...
  16. php一句话木马调用cmd命令,一句话木马(webshell)是如何执行命令的
  17. 速卖通,国际站卖家如何更高效进行测评
  18. Springboot毕设项目房地产销售管理系统70vd5(java+VUE+Mybatis+Maven+Mysql)
  19. 宿舍住宿管理java课程设计_宿舍管理系统Java课程设计
  20. oracle DG模式搭建详解

热门文章

  1. Android实现程序前后台切换效果
  2. Silverlight中使用CompositionInitializer宿主MEF
  3. iOS学习笔记--01swift实现提示框第三方库:MBProgressHUD
  4. [转]语音识别中区分性训练(Discriminative Training)和最大似然估计(ML)的区别...
  5. shell中大于、等于、小于
  6. java与c/c++之间的数据交互-----jni点滴
  7. 网站速度优化-前端篇
  8. Database design best practice(1):关于primary key及其它
  9. 通过构建城市来解释HTML,CSS和JavaScript之间的关系
  10. 异步回调地狱_如何逃避异步/等待地狱