码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 5233 Gunner II

时间:2015-05-24 14:10:06      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5233 
简单题,stl水之。。。

技术分享
 1 #include<algorithm>
 2 #include<iostream>
 3 #include<cstdlib>
 4 #include<cstdio>
 5 #include<set>
 6 using std::multiset;
 7 struct Node {
 8     int val, pos;
 9     Node(int _val = 0, int _pos = 0) :val(_val), pos(_pos){}
10 };
11 struct cmp{
12     bool operator()(const Node &a, const Node &b) const {
13         if (a.val == b.val) return a.pos < b.pos;
14         return a.val < b.val;
15     }
16 };
17 multiset<Node,cmp> rec;
18 int main() {
19 #ifdef LOCAL
20     freopen("in.txt", "r", stdin);
21     freopen("out.txt", "w+", stdout);
22 #endif
23     int n, m, v;
24     while (~scanf("%d %d", &n, &m)) {
25         for (int i = 1; i <= n; i++) {
26             scanf("%d", &v);
27             Node t(v, i);
28             rec.insert(t);
29         }
30         while (m--) {
31             scanf("%d", &v);
32             multiset<Node, cmp>::iterator ite = rec.lower_bound(v);
33             if (ite == rec.end() || v < ite->val) puts("-1");
34             else printf("%d\n", ite->pos), rec.erase(ite);
35         }
36         rec.clear();
37     }
38     return 0;
39 }
View Code

 

hdu 5233 Gunner II

标签:

原文地址:http://www.cnblogs.com/GadyPu/p/4525758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!