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
#include<bits/stdc++.h>
using namespace std;
pair <long long,long long> arr[300000+69];
map <long long,int> mapa;
int range_left[300000+69];
int range_right[300000+69];
bool vl[10000000+69];
bool visited[300000+69];;
queue <int> q;
int det(int l,int n){
	int v,i,r;
	for(i=0;i<n;i++){
		visited[i]=false;
		if(l%2)
			q.push(i);
		l/=2;
	}
	while(!q.empty()){
		v=q.front();
		q.pop();
		if(visited[v])
			continue;
		visited[v]=true;
		for(i=v-1;i>=range_left[v];i--)
			if(!visited[i])
				q.push(i);
		for(i=v+1;i<=range_right[v];i++)
			if(!visited[i])
				q.push(i);
	}
	r=0;
	for(i=n-1;i>=0;i--)
		r=r*2+(int)visited[i];
	//printf("%d\n",r);
	return r;
}
int main(){
	int n,i,m,j,p,result,pom;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lld%lld",&arr[i].first,&arr[i].second);
		mapa[arr[i].first]=i;
	}
	for(i=0;i<n;i++)
		range_left[i]=range_right[i]=i;
	for(i=1;i<n;i++)
		range_left[i]=range_left[(mapa.lower_bound(arr[i].first-arr[i].second)->second)];
	for(i=n-2;i>=0;i--)
		range_right[i]=range_right[(--mapa.upper_bound(arr[i].first+arr[i].second))->second];
	p=1;
	for(i=0;i<n;i++)
		p*=2;
	result=0;
	for(i=0;i<p;i++){
		pom=det(i,n);
		if(!vl[pom]){
			result++;
			vl[pom]=true;
		}
	}
	printf("%d\n",result);
	return 0;
}