public int upper_bound_ (int n, int v, int[] a) {
if(a[n-1]<=v ) return n+1;
// write code here
int begin=0;
int end=n-1;
int mid=(end+begin)/2;
while(begin<end){
if(a[mid]>=v){
end=mid;
}else{
begin = mid+1;
}
mid=(end+begin)/2;
}
return mid+1;
}
来源:oschina
链接:https://my.oschina.net/u/3126880/blog/4945469