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