#include <bits/stdc++.h>
#define ft first
#define sd second
#define pb push_back
#define nl "\n"
#define int long long
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 100100;
const int mod = 1e9 + 7;
signed main() {
int n;
cin >> n;
int l[n], r[n];
vector<int> v;
for (int i = 0; i < n; i++) {
cin >> l[i] >> r[i];
v.pb(i);
}
sort(v.begin(), v.end(), [&](int i, int j) {
return (i + r[i] < j + r[j]);
});
int k = 0;
int last = -1;
for (auto x: v) {
// cout << x << ' ';
if (last == -1 || (x - l[x] > last && last + r[last] < x)) {
k += 1;
last = x;
}
}
cout << k << nl;
}
/*
0 3
1 0
0 1
2 0
1 0
0 3 0
0 1 1
2 3
1 3
3 4
*/
// 1 0 2 3 4
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |