问题 4830 --盖房子

4830: 盖房子★★

时间限制: 1 Sec  内存限制: 128 MB
提交: 32  解决: 18
[提交][状态][命题人:]

题目描述

A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.

The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.

Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?

一个新山村建立起来了,目前为止山村中已建了n个平房。房屋的边都与x轴平行,没有任何两个房屋重叠,但房屋间可以相互接触。一个公司想在这个山村建一栋方形新房屋,
边长为 t,而且至少与一栋已有房屋互相接触。它的中心要在x轴上,且不与任何房屋重叠。请你求出新房屋共有多少种可能位置?

输入

The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 10001 ≤ ai ≤ 1000).

第一行为 n和t(1=<n,t<=1000).接下来n行,每行为xi,ai,分别为房屋中心坐标和房屋边长。( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).

输出

Output the amount of possible positions of the new house.

新房屋共有多少种可能位置。

样例输入
Copy
2 2
0 4
6 2
样例输出
Copy
4

提示

样例2输入

2 2
0 4
5 2

样例2输出

3

样例3输入

2 3
0 4
5 2

样例3输出

2

注:新房屋的坐标x可能不是整数

来源

[提交][状态]