```
class Solution {
public:
bool searchMatrix(vector<vector<int>>& matrix, int target) {
auto it = upper_bound(matrix.begin(),matrix.end(), target, [](int t, vector<int>& v){return t < v[0];}) - 1;
return it != matrix.begin() - 1 && binary_search(it->begin(), it->end(), target);
}
};
```