#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define int long long
#define double long double
#define codetiger_orz cin.tie(0);cin.sync_with_stdio(0);
signed main() {
codetiger_orz
int n;
cin >> n;
vector<pair<int, int>> v(n);
for (int i = 0; i < n; i++){
cin >> v[i].first >> v[i].second;
v[i] = {v[i].first + v[i].second, v[i].second - v[i].first};
}
sort(v.begin(), v.end());
stack<int> stk;
for (int i = 0; i < n; i++){
while (!stk.empty() && stk.top() <= v[i].second){
stk.pop();
}
stk.push(v[i].second);
}
cout << stk.size() << "\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... |