1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<cstdio>
#include<set>

typedef long long ll;

int n;
ll * a;
ll * r;
ll * c;

void input() {
  scanf("%d", &n);
  a = new ll[n];
  r = new ll[n];
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", a + i, r + i);
  }
}

// ll abs(ll a) {
//   return a < 0 ? -a : a;
// }

void code() {
  c = new ll[n];
  for (int i = 0; i < n; i++) {
    c[i] = (1 << i);
    bool changed = true;
    while(changed) {
      changed = false;
      for (int j = 0; j < n; j++) {
        if ((c[i] & (1 << j)) != 0) {
          for (int k = 0; k < n; k++) {
            if ((c[i] & (1 << k)) == 0 && abs(a[j] - a[k]) <= r[j]) {
              c[i] |= (1 << k);
              changed = true;
            }
          }
        }
      }
    }
  }
  // for (int i = 0; i < n; i++) {
  //   printf("%d %lld\n", i, c[i]);
  // }
}

int count() {
  std::set<ll> s1;
  std::set<ll> s2;
  s1.insert(0ll);
  for (int i = 0; i < n; i++) {
    for (std::set<ll>::iterator it = s1.begin(); it != s1.end(); it++) {
      // printf("%lld %lld\n", c[i], c[i] | *it);
      s2.insert(c[i] | *it);
      s2.insert(c[i]);
      s2.insert(*it);
    }
    s1 = std::set<ll>(s2);
    // printf("size %lu %lu\n", s2.size(), s1.size());
    s2.clear();
  }
  return s1.size();
}

int main() {
  input();
  code();
  printf("%d\n", count());
  return 0;
}