1. 程式人生 > >lower_bound &&upper_bound

lower_bound &&upper_bound

fin etc con gis pac ostream long ++ sort

詳見代碼

應該會明白這個的意思

#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; }

lower_bound &&upper_bound