/* 最左边n结束,>> 位移运算,low = mid + 1,high = mid; */ int upper_bound_(int n, int v, vector<int>& a) { int low = 0,high = n; while(low<high){ int mid =low+high >> 1;//位移运算优先级低于+-*/ a[mid]<v?low=mid+1:high=mid; //最先找到满足大于等于v的最小下标值 } return low+1; }
/* 最左边n结束,>> 位移运算,low = mid + 1,high = mid; */ int upper_bound_(int n, int v, vector<int>& a) { int low = 0,high = n; while(low<high){ int mid =low+high >> 1;//位移运算优先级低于+-*/ a[mid]<v?low=mid+1:high=mid; //最先找到满足大于等于v的最小下标值 } return low+1; }