#include <bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
array<int,2>arr[n];
for(int i = 0;i<n;i++){
cin >> arr[i][0];
cin >> arr[i][1];
}
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... |