C++二分标准模板

class Solution {
public:
    int upper_bound_(int n, int v, vector<int>& a) {
        int l = 0, r = n;
        while(l < r) {
            int mid = l + r >> 1;
            if(a[mid] < v) l = mid + 1;
            else r = mid;
        }
        return l + 1;
    }
};