Problem 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−thbird 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

Huge input, fast IO is recommended.

 
Source
BestCoder Round #36 ($)

用map保存数量即可。

 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include<iostream>
 3 #include<cstdio>
 4 #include<cstring>
 5 #include<cmath>
 6 #include<math.h>
 7 #include<algorithm>
 8 #include<queue>
 9 #include<set>
10 #include<bitset>
11 #include<map>
12 #include<vector>
13 #include<stdlib.h>
14 #include <stack>
15 using namespace std;
16 #define PI acos(-1.0)
17 #define max(a,b) (a) > (b) ? (a) : (b)
18 #define min(a,b) (a) < (b) ? (a) : (b)
19 #define ll long long
20 #define eps 1e-10
21 #define MOD 1000000007
22 #define N 1000000
23 #define inf 1e12
24 int n,m;
25 map<int,int>mp;
26 int main()
27 {
28    while(scanf("%d%d",&n,&m)==2){
29       mp.clear();
30       for(int i=0;i<n;i++){
31          int x;
32          scanf("%d",&x);
33          mp[x]++;
34       }
35       for(int i=0;i<m;i++){
36          int x;
37          scanf("%d",&x);
38          printf("%d\n",mp[x]);
39          mp[x]=0;
40       }
41    }
42     return 0;
43 }

View Code

hdu 5199 Gunner(STL之map,水)相关推荐

  1. STL之Map和MFC之CMap比较学习

    在MFC中,有CMap相关的map类, 在 map中有map. // Maps (aka Dictionaries)      class CMapWordToOb;         // map f ...

  2. c++ map是有序还是无序的_C++ STL中Map的按Key排序和按Value排序

    map是用来存放键值对的数据结构,可以很方便快速的根据key查到相应的value.假如存储学生和其成绩(假定不存在重名,当然可以对重名加以区分),我们用map来进行存储就是个不错的选择. 我们这样定义 ...

  3. STL之map中排序方式的重载

    map中的数据默认是按key值字典序排的 栗子: #include <iostream> #include <map> using namespace std; //typed ...

  4. stl中map函数_map :: empty()函数以及C ++ STL中的Example

    stl中map函数 C ++ STL映射:: empty() (C++ STL map::empty()) It is built-in function in C++ STL and used to ...

  5. STL 中map的用法详解

    STL 中map的用法详解 Map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力,由于这个特性,它完成有可 ...

  6. stl中map函数_map :: max_size()函数,以及C ++ STL中的Example

    stl中map函数 C ++ STL映射:: max_size() (C++ STL map::max_size() ) It returns the maximum number of elemen ...

  7. 转 STL hash_map map

    几句话道出map和hash_map的区别 1. STL map is an associative array where keys are stored in sorted order using ...

  8. C++ STL中Map的按Key排序和按Value排序

    map是用来存放<key, value>键值对的数据结构,可以很方便快速的根据key查到相应的value.假如存储学生和其成绩(假定不存在重名,当然可以对重名加以区分),我们用map来进行 ...

  9. C++ STL容器 —— map/multimap 用法详解

    C++ STL容器 -- map/multimap 用法详解 写在前面:近期正在学习C++的STL容器,因此在这里做一下日志记录,主要介绍一些容器基本成员函数的用法, 配上实际用例,并不涉及原理.但别 ...

最新文章

  1. portlet 与 servlet 的关系
  2. 讲一点分布式的基础知识,图解!
  3. 抛出错误Debug Assertion Failed!
  4. 生成 Heap Dump 的几种方式
  5. mysql oracle 表空间大小_最简单的查询表空间的使用量、剩余量的方法 - Focus on Oracle、MySQL and GNU/Linux...
  6. ant-design tree 设置默认选中状态_快速掌握文件夹位置的更改和文件的默认打开方式及重命名的操作...
  7. python列表修改元素_如何在Python中替换多维列表的第n个元素?
  8. SQL68 牛客每个人最近的登录日期(三)
  9. 步进电机原理及参数详解
  10. css border属性简写
  11. ssm基于微信平台的牙科就诊信息管理系统的设计与实现 毕业设计源码211157
  12. 2020.1.1 只争朝夕,不付韶华
  13. 第十三篇 Python建模库介绍
  14. 【ZBH选讲·模数和】
  15. onsubmit函数触发事件
  16. Java入门日记1 | 第一周总结
  17. windows server 2012r2 加入域操作
  18. C# Base64转换
  19. 苹果拟4亿美元收购音乐识别软件Shazam
  20. 解密豌豆荚应用内搜索协议:普适 经济 兼容

热门文章

  1. web工程中的各种路径(eclipse开发)
  2. getOwnPropertyNames() keys()
  3. phpstudy php日志,phpstudy开启网站Apache日志并且按照日期划分创建
  4. 中望cad2018中文版
  5. Docker 制作镜像-redis
  6. 生产订单新增按钮没权限
  7. Java核心技术点之多线程2
  8. 用webgl打造自己的3D迷宫游戏
  9. IOS UIWebView用法
  10. 软件测试学习笔记:找代码中的fault,并设计特定的测试用例