- lower_bound
int find(vector<int> &a,int val)//lower_bound
{
int l=0,r=a.size()-1;
while(l<=r)
{
int mid=(l+r)>>1;
if(a[mid]<val)l=mid+1;
else
r=mid-1;
}
return l;
}
- upper_bound
int find(vector<int> &a,int val)//upper_bound
{
int l=0,r=a.size()-1;
while(l<=r)
{
int mid=(l+r)>>1;
if(a[mid]<=val)l=mid+1;
else
r=mid-1;
}
return l;
}