题解
2026-05-31 13:13:35
发布于:浙江
4阅读
0回复
0点赞
其实跟上道lower_bound差不多
这题会了那题也能做
用lower_bound和upper_bound真简单得不得了
参考代码:
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,cnt = 0,m,s,a[100010];
cin >> n;
for (int i = 1;i <= n;i++){
cin >> a[i];
}
cin >> m;
sort (a + 1,a + n + 1);
for (int i = 1;i <= m;i++){
cin >> s;
//cnt = 0;
cnt = upper_bound (a + 1,a + n + 1,s) - a;
cout << n - cnt + 1 << endl;
}
return 0;
}
这里空空如也




有帮助,赞一个