hdu 5199 Gunner(STL之map,水)
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.
There are multiple test cases (about ), 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[],h[],h[],…,h[n] which describes the height of the trees. In the third line, there are m numbers q[],q[],q[],…,q[m] which describes the height of the Jack’s shots. Please process to the end of file. [Technical Specification] ≤n,m≤() ≤h[i],q[i]≤() All inputs are integers.
For each q[i], output an integer in a single line indicates the number of birds Jack shot down.
Huge input, fast IO is recommended.
用map保存数量即可。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 1000000
#define inf 1e12
int n,m;
map<int,int>mp;
int main()
{
while(scanf("%d%d",&n,&m)==){
mp.clear();
for(int i=;i<n;i++){
int x;
scanf("%d",&x);
mp[x]++;
}
for(int i=;i<m;i++){
int x;
scanf("%d",&x);
printf("%d\n",mp[x]);
mp[x]=;
}
}
return ;
}
hdu 5199 Gunner(STL之map,水)的更多相关文章
- hdu 5199 Gunner
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5199 简单题,stl水之... #include<algorithm> #include& ...
- HDU 2112 HDU Today(STL MAP + Djistra)
题目链接:HDU Today 立即集训要開始,抓紧时间练练手,最短路的基础题,第一次用STL的map 题目非常水,可是错了N遍.手贱了.本题不优点理的就是把地名转化为数字 #include <i ...
- HDOJ/HDU 1251 统计难题(字典树啥的~Map水过)
Problem Description Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己 ...
- HDU 2096 小明A+B --- 水题
HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...
- C++ STL中Map的按Key排序和按Value排序
map是用来存放<key, value>键值对的数据结构,可以很方便快速的根据key查到相应的value.假如存储学生和其成绩(假定不存在重名,当然可以对重名加以区 分),我们用map来进 ...
- STL中map与hash_map的比较
1. map : C++的STL中map是使用树来做查找算法; 时间复杂度:O(log2N) 2. hash_map : 使用hash表来排列配对,hash表是使用关键字来计算表位置; 时间复杂度:O ...
- STL中map,set的基本用法示例
本文主要是使用了STL中德map和set两个容器,使用了它们本身的一些功能函数(包括迭代器),介绍了它们的基本使用方式,是一个使用熟悉的过程. map的基本使用: #include "std ...
- STL中map与hash_map容器的选择收藏
这篇文章来自我今天碰到的一个问题,一个朋友问我使用map和hash_map的效率问题,虽然我也了解一些,但是我不敢直接告诉朋友,因为我怕我说错了,通过我查询一些帖子,我这里做一个总结!内容分别来自al ...
- C++ STL中Map的相关排序操作:按Key排序和按Value排序 - 编程小径 - 博客频道 - CSDN.NET
C++ STL中Map的相关排序操作:按Key排序和按Value排序 - 编程小径 - 博客频道 - CSDN.NET C++ STL中Map的相关排序操作:按Key排序和按Value排序 分类: C ...
随机推荐
- codecomb 2100【警察叔叔就是这个人!】
题目背景 十个地方十人十色 全部都是猥琐大叔 这里也是那里也是 行踪可疑 现如今hentai横行,警察叔叔们不得不采取特♂殊手段惩戒这些家伙 题目描述 魅力之都是一个有N个路口,M条双向道路连接的城市 ...
- sroHOBOorz来自HOBO的高精类
/* bigint() bigint(long long) bigint(bigint) bigint(char*) bigint(string) +, +=, ++ -, -=, -- *, *= ...
- 修改MySQL 5.5的max_allowed_packet属性的方法
今天在部署一个实验系统的时候,报出下面这个错: Your 'max_allowed_packet' variable is set to less than 16777216 Byte (16MB). ...
- C#执行zip文件压缩的几种方法及我遇到的坑总结
工作项目中需要用到zip压缩解压缩文件,一开始看上了Ionic.Zip.dll这个类库,操作方便,写法简单 对应有个ziphelper类 using Ionic.Zip; public static ...
- jquery实现仿商品星级评价
一,HTML部分 <div id="rating-star"> <a href="#">0</a> < ...
- 在浏览器中输入Google.com并且按下回车之后发生了什么?
作者: skyline75489 来源: skyline75489的博客 发布时间: 2015-03-26 16:57 阅读: 4163 次 推荐: 23 原文链接 [收藏] ...
- HINTERNET 句柄
这篇文章的内容能够简单总结例如以下: WinINet函数创建和使用类型为HINTERNET的句柄 HINTERNET句柄不能与其它类型的句柄互换使用 用InternetCloseHandle关闭HIN ...
- 浅谈postMessage多页面监听事件
最近做了一个Echarts和Highcharts多图多页面连动的效果,就用到postMessage 如下介绍: 最开始在最外围的页面也就是所有页面的父级页面添加postMessage监听事件以便监听下 ...
- SQL Server T-SQL基础
--数据库:数据库软件:mssqlserver,oracle,db2, ACCESS,SQLITE --数据库文件:分数据文件(MDF)和日志文件(log) 班级名称:(四期班训练营)长度可变,有中文 ...
- OpenGL教程之碰撞检测与模型运动
下面我们要讨论的是如何快速有效的检测物体的碰撞和合乎物理法则的物体运动,先看一下我们要学的: 1)碰撞检测 ·移动的范围 — 平面 ·移动的范围 — 圆柱 ·移动的范围 — 运动的物体 2)符合物理规 ...