Untitled
unknown
plain_text
3 years ago
425 B
9
Indexable
int minNum(int threshold,vector<int> points)
{
int n=points.size();
if(points[n-1]-points[0]<threshold)return n;
int l=0,r=n-1;
int target=threshold+points[0];
int ind=n-1;
while(l<=r)
{
int mid=(l+r)/2;
if(points[mid]>target)
{
ind=mid;
r=mid-1;
}
else
l=mid+1;
}
return 1+ (ind+1)/2;
}
Editor is loading...