This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int N; cin >> N;
vector<pair<int, int>> v(N);
for(int i = 0; i < N; i++){
cin >> v[i].first >> v[i].second;
}
sort(v.begin(), v.end());
int useless = 0;
set<pair<int, int>> left;
int mxVal = -2e9;
for(int i = 0; i < N; i++){
int val1 = v[i].second - v[i].first;
int val2 = v[i].first + v[i].second;
if(mxVal >= val2){
useless++;
continue;
}
mxVal = val2;
while(!left.empty() && (*left.begin()).first <= val1){
useless++;
left.erase(left.begin());
}
left.insert({val1, i});
}
cout << N - useless << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |