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. js 产生随机数

    这里整理了几个产生随机数的方法: 1.generateUUID() //获取一个唯一数 function generateUUID() { var d = new Date().getTime(); ...

  2. FakeID签名漏洞分析及利用(一)

    作者:申迪   转载请注明出处: http://blogs.360.cn/360mobile BlueBox于7月30日宣布安卓从2010年以来一直存在一个apk签名问题[1],并且会在今年Black ...

  3. 20155210 实验一 逆向与Bof基础

    20155210 实验一 逆向与Bof基础 实验内容 1.直接修改程序机器指令,改变程序执行流程 下载目标文件pwn1,反汇编 利用objdump -d pwn1对pwn1进行反汇编 得到: 8048 ...

  4. 20155234 exp4 恶意代码分析

    实验4 恶意代码分析 系统运行监控 Schtasks 先建立一个netstat20155234.txt文件,在文件中输入 date /t >> c:\netstat20155234.txt ...

  5. 20155238 Java第13周课堂实践

    类定义 实验内容及要求 设计并实现一个Book类,定义义成Book.java,Book 包含书名,作者,出版社和出版日期,这些数据都要定义getter和setter.定义至少三个构造方法,接收并初始化 ...

  6. 20155238 2016-2017-2 《JAVA程序设计》第八周学习总结

    教材学习内容总结 第十四章 NIO NIO使用频道(Channel)来衔接数据节点,处理数据时,NIO可以让你设定缓冲区(Buffer)容量, 在缓冲区对感兴趣的数据区块进行标记,对于这些标记,提供了 ...

  7. PostgreSQL基础知识与基本操作索引页

    磨砺技术珠矶,践行数据之道,追求卓越价值 返回顶级页:PostgreSQL索引页 luckyjackgao@gmail.com 本页记录所有本人所写的PostgreSQL的基础知识和基本操作相关文摘和 ...

  8. python 回溯法 子集树模板 系列 —— 19、野人与传教士问题

    问题 在河的左岸有N个传教士.N个野人和一条船,传教士们想用这条船把所有人都运过河去,但有以下条件限制: (1)修道士和野人都会划船,但船每次最多只能运M个人: (2)在任何岸边以及船上,野人数目都不 ...

  9. Jenkins控制台输出乱码

    一.问题详情 jenkins构建mav任务,在控制台显示乱码: 二.原因分析 1. 查看系统编码和tomcat的编码都正常 # grep encoding /usr/local/tomcat/conf ...

  10. Android几行代码实现监听微信聊天

    原创作品,转载请注明出处,尊重别人的劳动果实. 2017.2.7更新: *现在适配微信版本更加容易了,只需要替换一个Recourse-ID即可 *可以知道对方发的是小视频还是语音,并获取秒数. *可以 ...