#include <bits/stdc++.h>
using namespace std;
inline int readInt() {
int x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') ch = getchar_unlocked();
while (ch >= '0' && ch <= '9'){
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
return x;
}
int X[10000000], Y[10000000];
int main(){
int n = readInt();
array<int,2>arr[n];
for(int i = 0; i < n; i++) {
X[i] = readInt();
Y[i] = readInt();
arr[i][0]=X[i];
arr[i][1]=Y[i];
}
int p[n];
fill(p,p+n,-1);
int prev = 0;
for(int i = 1;i<n;++i){
if(arr[i][0]-arr[prev][0]<=arr[prev][1]-arr[i][1]){
p[i]=prev;
}
else{
prev=i;
}
}
prev=n-1;
for(int i = n-2;i>=0;--i){
if(arr[prev][0]-arr[i][0]<=arr[prev][1]-arr[i][1]){
p[i]=prev;
}
else{
prev=i;
}
}
int ans = 0;
for(int i = 0;i<n;++i){
if(p[i]==-1){
ans++;
}
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |