Problem:
Score : 200 points

Problem Statement

In a factory, there are N robots placed on a number line.
Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.

We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.
Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.

Find the maximum number of robots that we can keep.

Constraints

1 \leq N \leq 100,000

0 \leq X_i \leq 10^9 (1 \leq i \leq N)

1 \leq L_i \leq 10^9 (1 \leq i \leq N)

If i \neq j, X_i \neq X_j.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
X_1 L_1
X_2 L_2
\vdots
X_N L_N

Output

Print the maximum number of robots that we can keep.

Sample Input 1

4
2 4
4 3
9 3
100 5

Sample Output 1

3

By removing Robot 2, we can keep the other three robots.

Sample Input 2

2
8 20
1 10

Sample Output 2

1

Sample Input 3

5
10 1
2 1
4 1
6 1
8 1

Sample Output 3

5

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 1e9, MAX = 600000, N = 200005;
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

struct BIT {
	int Max[MAX + 5];
	void modify(int pos, int val) {
		for (int i = pos; i <= MAX; i += i & -i)
			chkmax(Max[i], val);
	}
	int query(int pos) {
		if (!pos) return 0;
		if (pos < 0) return -inf;
		int res = 0;
		for (int i = pos; i; i ^= i & -i)
			chkmax(res, Max[i]);
		return res;
	}
}bit;

int n;
struct Node {
	int x, l, r;
}a[N];
int num[N << 3], tot;

inline bool cmp(Node &a, Node &b) { return a.x < b.x; }

signed main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif
	ios::sync_with_stdio(false);

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int L;
		cin >> a[i].x >> L;
		a[i].l = a[i].x - L;
		a[i].r = a[i].x + L;
		num[++tot] = a[i].x;
		num[++tot] = a[i].l;
		num[++tot] = a[i].r;
	}

	sort(num + 1, num + tot + 1);
	for (int i = 1; i <= n; ++i) {
		a[i].x = lower_bound(num + 1, num + tot + 1, a[i].x) - num;
		if (a[i].l >= 0)
			a[i].l = lower_bound(num + 1, num + tot + 1, a[i].l) - num;
		else a[i].l = 0;
		a[i].r = lower_bound(num + 1, num + tot + 1, a[i].r) - num;
	}
	sort(a + 1, a + n + 1, cmp);

	for (int i = 1; i <= n; ++i) {
		bit.modify(a[i].x, bit.query(a[i].l - 1) + 1);
		bit.modify(a[i].r, bit.query(a[i].x - 1) + 1);
	}

	printf("%d\n", bit.query(MAX));
	return 0;
}