#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 cmp1(pp a, pp b){
if (a.F != b.F)
return (a.F < b.F);
return (a.S > b.S);
}
bool cmp2(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;
sort(v.begin(), v.end(), cmp1);
for (int i = 0; i < (int)(v.size()); ++i)
if (!i || v[i].F != v[i - 1].F) v2.pb(v[i]);
v = v2; v2.clear(); int x = -INF;
for (int i = 0; i < (int)(v.size()); ++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;
sort(v.begin(), v.end(), cmp2);
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... |