You are given two arrays of integers a and b. For each element of the second arraybj you should find the number of elements in array a that are less than or equal to the value bj.

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays aand b.

The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109).

The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).

Output

Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.

Examples

Input
5 4
1 3 5 7 9
6 4 2 8
Output
3 2 1 4
Input
5 5
1 2 1 2 5
3 1 4 1 5
Output
4 2 4 2 5

排个序 二分即可 
upper_bound即可

#include <bits/stdc++.h>
using namespace std;
vector<int> g;
vector<int> v; int main()
{
int n, m;
cin>> n >> m;
for(int i=; i<n; i++)
{
int tmp;
cin>> tmp;
v.push_back(tmp);
}
for(int i=; i<m; i++)
{
int tmp;
cin>> tmp;
g.push_back(tmp);
}
sort(v.begin(), v.end());
int len = g.size();
for(int i=; i<len; i++)
{
if(i!=)
cout<< " ";
cout<< upper_bound(v.begin(), v.end(), g[i]) - v.begin();
}
cout<<endl; return ;
}

Queries about less or equal elements CodeForces - 600B(二分)的更多相关文章

  1. CodeForces - 600B Queries about less or equal elements (二分查找 利用stl)

    传送门: http://codeforces.com/problemset/problem/600/B Queries about less or equal elements time limit ...

  2. CF 600B Queries about less or equal elements --- 二分查找

    CF 600B 题目大意:给定n,m,数组a(n个数),数组b(m个数),对每一个数组b中的元素,求数组a中小于等于数组该元素的个数. 解题思路:对数组a进行排序,然后对每一个元素b[i],在数组a中 ...

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

    B. Queries about less or equal elements Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforc ...

  4. Educational Codeforces Round 2_B. Queries about less or equal elements

    B. Queries about less or equal elements time limit per test 2 seconds memory limit per test 256 mega ...

  5. Codeforces 600B Queries about less or equal elements(二分查找)

    Description You are given two arrays of integers a and b. For each element of the second array bj yo ...

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

    打开题目连接 题意:给2个数组(无序的)啊a,b,判断b数组中的每一个元素大于a数组中个数. ACcode: #include <iostream> #include <vector ...

  7. Many Equal Substrings CodeForces - 1029A (kmp next数组应用)

    题目大意 题目看样例也能猜到就是输出最短的循环串. 吐槽 明明是div3第一题为啥子还会用到kmp的知识? 解法 这个题仔细看发现是求最长可去除的后缀,也就是说去除跟下一个相同的字符串还能连接起来.这 ...

  8. CodeForces - 363D --二分和贪心

    题目:CodeForces - 363D 题意:给定n个学生,其中每个学生都有各自的私己钱,并且自己的私己钱只能用在自己买自行车,不能给别人. 给定m个自行车,每个自行车都有一个价格. 给定公有财产a ...

  9. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

随机推荐

  1. HDU 2159 FATE(有选择物品总个数限制的完全背包,经典!!)

    FATE Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  2. ansible-playbook如何判断并中断执行

    - fail: msg="Bailing out. this play requires 'bar'"       when: bar is not defined 我的需求是当某 ...

  3. Linux中的do{...} while(0)

    摘抄自: <<Linux设备驱动开发详解(第二版)>> 在 Linux 内核中,经常会看到do{} while(0)这样的语句,许多人开始都会疑惑,认为do{} while(0 ...

  4. 20155216 Exp3 免杀原理与实践

    Exp3 免杀原理与实践 基于特征码的改变来实现免杀(实践过程记录) MSF编码器编译后门检测 可以通过VirSCAN来检验后门抗杀能力. ps:选择后门前修改其文件名,不得含有数字. 如上图所示,3 ...

  5. 20155301 Exp9 Web安全基础

    20155301 Exp9 Web安全基础 1.实验后回答问题 (1)SQL注入攻击原理,如何防御 答 :原理: 利用现有应用程序,将恶意的SQL命令注入到后台数据库引擎执行的能力,它可以通过在Web ...

  6. 2017-2018-2 《网络对抗技术》 20155302 第二周 Exp1 PC平台逆向破解(5)M

    2017-2018-2 <网络对抗技术> 20155302 第二周 Exp1 PC平台逆向破解(5)M 1-实践目标 1.1-实践介绍 本次实践的对象是一个名为pwn1的linux可执行文 ...

  7. WPF自定义控件的自定义属性绑定后不更新问题

    原文:WPF自定义控件的自定义属性绑定后不更新问题 需要在绑定时设置属性变更触发 UpdateSourceTrigger=PropertyChanged 例如: <Border CornerRa ...

  8. Android开发——Fragment知识整理(一)

    0.  前言 Fragment,顾名思义是片段的意思,可以把Fragment当成Activity的一个组成部分,甚至Activity的界面可以完全有不同的Fragment组成.Fragment需要被嵌 ...

  9. 【第七课】Nginx反向代理和负载均衡

    目录 一.Nginx负载均衡集群 介绍 二.实现一个简单的负载均衡 三.Nginx负载均衡组件介绍 四.Nginx负载均衡实际应用 一.Nginx负载均衡集群 介绍 负载均衡(Load Balance ...

  10. ElasticSearch查询 第一篇:搜索API

    <ElasticSearch查询>目录导航: ElasticSearch查询 第一篇:搜索API ElasticSearch查询 第二篇:文档更新 ElasticSearch查询 第三篇: ...