Cidefirces educational codeforces Round 2 B Queries about less or equal elements

Source: Internet
Author: User

B. Queries about less or equal elements

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

Input

The first line contains integers n, m (1≤ n, m ≤2 105)-th e Sizes of Arrays a and b.

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

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

Output

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

Sample Test (s) 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
1#include <cstdio>2#include <vector>3#include <cmath>4#include <queue>5#include <map>6#include <cstring>7#include <algorithm>8 using namespacestd;9typedefLong Longll;Tentypedef unsignedLong Longull; One Const intmaxn=2e5+5; A intMain () - { -     intn,m; the     intA[MAXN]; -scanf"%d%d",&n,&m); -      for(intI=0; i<n;i++) -scanf"%d",&a[i]); +Sort (a,a+n); -      for(intI=0; i<m;i++) +     { A         inttt; atscanf"%d",&TT); -         intPos=lower_bound (a,a+n,tt+1)-A; -printf"%d", POS); -     } -     return 0; -}

Cidefirces educational codeforces Round 2 B Queries about less or equal elements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.