#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pp pair<int, int>
#define F first
#define S second
const int INF = 2 * 1e9 + 100;
int n;
bool cmp(pp a, pp b){
return (a.F > b.F);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
vector<pp> v(n);
for (int i = 0; i < n; ++i)
cin >> v[i].F >> v[i].S;
vector<pp> v2; int x = -INF;
sort(v.begin(), v.end());
for (int i = 0; i < n; ++i)
if (v[i].S + v[i].F > x) v2.pb(v[i]), x = v[i].F + v[i].S;
v = v2; v2.clear(); x = -INF;
//for (auto p: v) cout << "! " << p.F << ' ' << p.S << endl;
sort(v.begin(), v.end(), cmp);
for (int i = 0; i < (int)(v.size()); ++i)
if (v[i].S - v[i].F > x) v2.pb(v[i]), x = v[i].S - v[i].F;
cout << (int)(v2.size());
return 0;
}
# | 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... |