intmy_lower_bound(int l, int r, int v){ int mid, ans; while (l <= r) { mid = l + r >> 1; if (a[mid] >= v) ans = mid, r = mid - 1; else l = mid + 1; } return ans; }
upper_bound
1 2 3 4 5 6 7 8 9
intmy_lower_bound(int l, int r, int v){ int mid, ans; while (l <= r) { mid = l + r >> 1; if (a[mid] >= v) ans = mid, r = mid - 1; else l = mid + 1; } return ans; }