题解
2023-07-10 14:46:31
发布于:上海
43阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int n;
int f(int x){
int l=0, r=n+1;
while(l+1 != r){
int mid = l + r >> 1;
if(a[mid] <= x){
l = mid;
}else{
r = mid;
}
}
return n - r + 1;
}
int main(){
cin>>n;
for(int i=1; i<=n; i++)
cin>>a[i];
sort(a+1, a+n+1);
int m; cin>>m;
while(m--){
int x; cin>>x;
cout << f(x) << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个