#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define ff first
#define ss second
#define pint pair < int , int >
#define fast ios_base::sync_with_stdio(NULL); cin.tie(NULL)
typedef vector < int > vint;
const int inf = 1e9 + 9;
const int mxn = 5e5 + 2;
const int mod = 1e9 + 7;
int x[mxn] , y[mxn];
int main() {
int n;
cin >> n;
vector < tuple < int , int , int > > v;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
v.push_back({-y[i] + x[i] , -x[i] , y[i]});
}
sort(v.begin() , v.end());
int t = -inf;
int ans = 0;
for (auto tup : v) {
int yint , xx , yy;
tie(yint , xx , yy) = tup;
xx = -xx;
if (xx + yy > t) {
ans++;
t = xx + yy;
}
}
cout << ans << '\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... |