首页 > 其他 > 详细

Educational Codeforces Round 2 B. Queries about less or equal elements

时间:2015-12-19 14:53:28      阅读:243      评论:0      收藏:0      [点我收藏+]

打开题目连接

题意:给2个数组(无序的)啊a,b,判断b数组中的每一个元素大于a数组中个数。

ACcode:

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
vector<int> v;
int main()
{
    int x, n, m;
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&x);
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=0; i<m; i++)
    {
        scanf("%d", &x);
        int pos = lower_bound(v.begin(),v.end(), x+1)- v.begin();
        printf("%d ",pos);
    }
     printf("\n");

    return 0;
}

  lower_bound的详细: 参考链接 

          vector的详细:参考链接

Educational Codeforces Round 2 B. Queries about less or equal elements

原文:http://www.cnblogs.com/lzeffort/p/5059026.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!