详见代码
应该会明白这个的意思
#include <iostream> #include <algorithm> using namespace std; typedef long long ll; inline ll read(){ ll x=0,f=1; char ch=getchar(); while(!isdigit(ch)) ch=='-'&(f=-1),ch=getchar(); while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); return x*f; } int n; const int N=1<<20; int a[N]; signed main(){ n=read(); for(register int i=1;i<=n;i++) a[i]=read(); sort(a+1,a+n+1); int find=read(); int l=lower_bound(a+1,a+n+1,find)-a; int r=upper_bound(a+1,a+n+1,find)-a; cout<<l<<' '<<r<<endl; return 0; }