题目链接
题意:给你一个数组a ,然后给你一个数组B,让你找出b[i]在A中有多少是小于他的
解法:排序a数组,二分查找即可
#define CF
#ifndef CF
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#else
#include<bits/stdc++.h>
#endif // CF
using namespace std;
#define LL long long
#define pb push_back
#define X first
#define Y second
#define cl(a,b) memset(a,b,sizeof(a))
typedef pair<long long ,long long > P;
const int maxn=2*100005;
const LL inf=1LL<<50;
const LL mod=1e9+7;
LL a[maxn],b[maxn];
int main(){
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
scanf("%lld",&a[i]);
}
for(int i=0;i<m;i++){
scanf("%lld",&b[i]);
}
sort(a,a+n);
for(int i=0;i<m;i++){
int p=upper_bound(a,a+n,b[i])-a;
if(i==0)printf("%d",p);
else printf(" %d",p);
}
puts("");
return 0;
}