#include <bits/stdc++.h>
#define file "main"
#define maxn (int) 5e4 + 5
#define ll long long
#define pii pair<int, int>
#define gb(i, j) ((i >> j) & 1)
#define all(x) x.begin(), x.end()
#define fi(i, a, b) for(int i = a; i <= b; i ++)
#define fid(i, a, b) for(int i = a; i >= b; i --)
#define f first
#define s second
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll GetRandom(ll l, ll r) {
return uniform_int_distribution<ll> (l, r) (rng);
}
int n;
pii a[maxn];
vector<int> cur;
set<int> S;
void solve() {
cin >> n ;
fi(i, 1, n) {
int x, y; cin >> x >> y;
a[i] = { x - y, x + y };
// cur.push_back(a[i].s), cur.push_back(a[i].f);
}
// sort( all(cur) );
// cur.resize(unique(all(cur)) - cur.begin());
//
// fi(i, 1, n) {
// a[i].f = lower_bound(all(cur), a[i].f) - cur.begin() + 1,
// a[i].s = lower_bound(all(cur), a[i].s) - cur.begin() + 1;
// }
sort( a + 1, a + n + 1, [](pii x, pii y) {
return x.f == y.f ? x.s > y.s : x.f < y.f;
});
int ans = 0;
fi(i, 1, n) {
if(S.empty() || S.lower_bound(a[i].s) == S.end()) ans ++;
S.insert(a[i].s);
}
cout << ans;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL), cout.tie(NULL);
if(fopen(file".inp", "r")) {
freopen(file".inp", "r", stdin);
// freopen(file".out", "w", stdout);
}
int nTest = 1;
// cin >> nTest;
while(nTest --) {
solve();
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
61 | freopen(file".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |