#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
struct node {
ll pos, h, l, r;
}p[N];
int dp[N][4];
int main() {
int n;cin >> n;
for (int i = 1; i <= n ;i ++) {
cin >> p[i].pos >> p[i].h;
p[i].l = p[i].pos - p[i].h;
p[i].r = p[i].pos + p[i].h;
}
int now = 0;
for (int i = 1; i <= n; i ++) {
if (i == 1 || i == n){
now++;
continue;
}
if (p[i].l > p[i-1].pos) {
now++;
} else {
if (p[i].r < p[i + 1].pos) {
now++;
p[i].pos = p[i].r;
}
}
}
cout << now << endl;
return 0;
}
原文:https://www.cnblogs.com/Xiao-yan/p/14738643.html