#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
signed main() {
int n; cin >> n;
vector<pair<int,int>> L(n), R(n);
for(int i=0;i<n;i++) {
int a, b; cin >> a >> b;
L[i].f = a-b, L[i].s = i, R[i].f = a+b, R[i].s = i;
}
sort(begin(L),end(L)); sort(begin(R),end(R));
vector<int> v(n); for(int i=0;i<n;i++) v[R[i].s] = i;
int ans = 0, x = -1, y = 0;
for(int i=0;i<n;i++) {
while(x < n-1) {
if(L[x+1].f == L[i].f) {
x++, y = max(y, v[L[x].s]);
while(y < n-1) {if(R[y+1].f == R[y].f) y++; else break;}
} else break;
}
if(v[L[i].s] >= y) ans++;
}
cout << ans;
}
# | 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... |