hdu 5233 Gunner II
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5233
简单题,stl水之。。。
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<set>
using std::multiset;
struct Node {
int val, pos;
Node(int _val = , int _pos = ) :val(_val), pos(_pos) {}
};
struct cmp {
bool operator()(const Node &a, const Node &b) const {
if (a.val == b.val) return a.pos < b.pos;
return a.val < b.val;
}
};
multiset<Node,cmp> rec;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int n, m, v;
while (~scanf("%d %d", &n, &m)) {
for (int i = ; i <= n; i++) {
scanf("%d", &v);
Node t(v, i);
rec.insert(t);
}
while (m--) {
scanf("%d", &v);
multiset<Node, cmp>::iterator ite = rec.lower_bound(v);
if (ite == rec.end() || v < ite->val) puts("-1");
else printf("%d\n", ite->pos), rec.erase(ite);
}
rec.clear();
}
return ;
}
hdu 5233 Gunner II的更多相关文章
- HDU 5233 Gunner II 离散化
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5233 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- 二分查找 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 ...
- HDU 3567 Eight II(八数码 II)
HDU 3567 Eight II(八数码 II) /65536 K (Java/Others) Problem Description - 题目描述 Eight-puzzle, which is ...
- HDU 2236 无题II(二分图匹配+二分)
HDU 2236 无题II 题目链接 思路:行列仅仅能一个,想到二分图,然后二分区间长度,枚举下限.就能求出哪些边是能用的,然后建图跑二分图,假设最大匹配等于n就是符合的 代码: #include & ...
- HDU 5919 Sequence II(主席树+逆序思想)
Sequence II Time Limit: 9000/4500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) To ...
- HDU 3567 Eight II
Eight II Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 3 ...
- HDU 5919 Sequence II 主席树
Sequence II Problem Description Mr. Frog has an integer sequence of length n, which can be denoted ...
- HDU 4043 FXTZ II (组合数学-排列组合)
FXTZ II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
随机推荐
- 将Excel中数据导入数据库(一)
在工作中经常要将Excel中数据导入数据库,这里介绍一种方法. 假如Excel中的数据如下: 数据库建表如下: 其中Id为自增字段: Excel中数据导入数据库帮助类如下: using System; ...
- PZISP自动下载软件运行时出现“应用程序无法启动,因为应用程序的并行配置不正确”
在win7下以管理员身份运行“PZISP自动下载软件”时出现“应用程序无法启动,因为应用程序的并行配置不正确”时,是因为系统里面没有一些visual c++库 想一想,反正以后也要用上VS2010的, ...
- 使用Apache CXF开发WebServices服务端、客户端
在前一篇的博客中,我使用Xfire1.x来开发了WebServies的服务端. 但是如果你访问Apache的官网,可以看到xfire已经被合并了. 最新的框架叫做CXF. Apache CXF = C ...
- CHARINDEX用法
CHARINDEX返回字符串中指定表达式的起始位置. 语法CHARINDEX ( expression1 , expression2 [ , start_location ] ) 参数expre ...
- dell n2000 组播抑制
http://en.community.dell.com/support-forums/network-switches/f/866/t/19677497 http://en.community.de ...
- .Net字符串驻留池
在.Net中,对于相同的字符串,.Net会将它们指向同一个地址,它们是相同的实例..Net中的字符串并不会更新,当更改一个字符串变量时,由于字符串的不可变性,.Net实际上是新创建一个字符串,而将变量 ...
- HTML中解决双击会选中文本的问题
HTML中解决双击会选中文本的问题 <div unselectable="on" style="-moz-user-select:none;" onsel ...
- HTTP CHUNKED C实现
C语言不像C#一样有很多很多高度的模块化的东西可以使用,在通讯过程中特别是与http相关的通讯过程中可能要对网站返回的数据做一定处理,而且有不少网站的回应是强制性的,例如向网站请求deflate有个能 ...
- hdu2067
如果i==j&&j-1>=0时候,f[i][j]=f[i][j-1]; 如果j==0时候,f[i][j]=1; 其他 f[i][j]=f[i-1][j]+f[i][j-1]; # ...
- Mysql远程登录授权
1.改表法. 请使用mysql管理工具,如:SQLyog Enterprise 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑使用mysql管理工 ...