原题链接: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的更多相关文章

  1. HDU 5233 Gunner II 离散化

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5233 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

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

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

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

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

  4. HDU 3567 Eight II(八数码 II)

    HDU 3567 Eight II(八数码 II) /65536 K (Java/Others)   Problem Description - 题目描述 Eight-puzzle, which is ...

  5. HDU 2236 无题II(二分图匹配+二分)

    HDU 2236 无题II 题目链接 思路:行列仅仅能一个,想到二分图,然后二分区间长度,枚举下限.就能求出哪些边是能用的,然后建图跑二分图,假设最大匹配等于n就是符合的 代码: #include & ...

  6. HDU 5919 Sequence II(主席树+逆序思想)

    Sequence II Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) To ...

  7. HDU 3567 Eight II

    Eight II Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 3 ...

  8. HDU 5919 Sequence II 主席树

    Sequence II Problem Description   Mr. Frog has an integer sequence of length n, which can be denoted ...

  9. HDU 4043 FXTZ II (组合数学-排列组合)

    FXTZ II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

随机推荐

  1. memcached 学习(一)

    memcached 是以LiveJournal 旗下Danga Interactive 公司的Brad Fitzpatric 为首开发的一款软件.现在已成为 mixi. hatena. Faceboo ...

  2. jquery zTree 查找所有的叶子节点

    jquery zTree 查找所有的叶子节点 // 保存所有叶子节点 10 为初始化大小,并非数组上限 var arrayObj = new Array([10]); /* treeNode: 根节点 ...

  3. ICDM 2007

    Language-Independent Set Expansion of Named Entities Using the Web. Chao Wang, Venu Satuluri, Sriniv ...

  4. 解决ScrollView下嵌套ListView、GridView显示不全的问题

    /** * 自定义gridview,解决ListView中嵌套gridview显示不正常的问题(1行半) * @author wangyx * @version 1.0.0 2012-9-14 */ ...

  5. C#中messagebox用法

    [函数] <整型> MessageBox(<字符串 Text, <字符串> Title, <整型> nType,MessageBoxIcon);[函数说明] ...

  6. C#基础知识点

    一.方法(结构.数组.冒泡排序.3个参数重载) 1将string转换为int类型 Convert.ToInt32(); int.Parse() ; int.TryParse()三种方式. 2 结构:可 ...

  7. 【MySQL】MySQL同步报错-> received end packet from server, apparent master shutdown: Slave I/O thread: Failed reading log event, reconnecting to retry报错解决和分析

    [root@db-ft-db-48 ~]# tail -f /mysqlLog/beside_index_err.log 140102 20:42:26 [Note] Slave: received ...

  8. ASP.NET的SEO:使用.ashx文件——排除重复内容

    本系列目录 不同的链接指向的页面如果具有大量相同的内容,这种现象就会被称为"重复内容",如果一个网站的重复内容很多,搜索引擎就会认为这个网站的价值不高.所以我们应尽量避免各种重复内 ...

  9. c++ boost--------------boost::progress_timer小试。

    //--------------------------------------------------------------------------- #include <vcl.h> ...

  10. hdu1864

    use the cnt as the limit. #include <string.h> #include <stdio.h> ],sum; ]; double a,b,c; ...