Lightning Rod
Time limit2.5sMemory limit512 MB
Given N buildings with tops at (X_i, Y_i), find the fewest buildings to place lightning rods on so that every building lies under a rod's 45-degree protection cone.
Statement
Singapore has between 171 and 186 lightning days on average per year. Each square kilometer of land in Singapore can be struck up to 16 times annually, which makes Singapore one of the lightning capitals of the world.
Gug the architect surveys buildings from left to right. The top of building is at coordinates . Gug wants to protect all the buildings by planting lightning rods on the tops of some buildings. A lightning rod protects the building it is planted on, along with every building that lies on or under the 45 degree line of depression going left and right from it. In other words, a lightning rod on building protects building if and only if .
Find the minimum number of lightning rods needed to protect all buildings.
Input
The first line contains a single integer , the number of buildings. Each of the next lines contains two integers and . It is given that , so is non-decreasing.
The input is very large, so C++ fast input is needed to receive full credit.
Output
Print one integer, the minimum number of lightning rods required to protect all buildings.
Constraints