hdu 5199 Gunner

来源:互联网 发布:2017年淘宝新规则 编辑:程序博客网 时间:2024/05/22 03:17

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

#include<algorithm>#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<set>#include<map>using std::map;map<int, int> rec;int main() {#ifdef LOCAL    freopen("in.txt", "r", stdin);    freopen("out.txt", "w+", stdout);#endif    int n, v, k;    while (~scanf("%d %d", &n, &k)) {        for (int i = 0; i < n; i++) {            scanf("%d", &v);            rec[v]++;        }        while (k--) {            scanf("%d", &v);            map<int, int>::iterator ite = rec.lower_bound(v);            if (ite == rec.end() || ite->first > v) puts("0");            else printf("%d\n", ite->second), rec.erase(v);        }    }    return 0;}
0 0