Toppling Dominoes (Small)

Sort the dominoes by position and find the minimum number of manual pushes so that chains topple every domino.

Hard8Dynamic programmingSortingGreedyNo attempts yetTime limit1sMemory limit512 MB

Problem

NN dominoes stand in a row on a number line. Domino ii stands at position XiX_i with height HiH_i, and no two dominoes share a position.

Hongjun can pick one domino and push it over to the left or to the right. When a domino of height hh at position xx falls to the left, every domino whose position is at least xhx-h and at most xx falls to the left. When it falls to the right, every domino whose position is at least xx and at most x+hx+h falls to the right. A domino knocked over this way keeps the same direction and topples the dominoes around it in turn, and the chain continues until nothing is left to fall.

Hongjun wants every domino on the ground with as few pushes of his hand as possible. Write a program that computes how many pushes he needs.

Input

The first line contains the number of dominoes NN. (1N3001 \le N \le 300)

Each of the next NN lines contains two integers XiX_i and HiH_i, the position and the height of one domino, separated by a space. (1Xi,Hi20000000001 \le X_i, H_i \le 2\,000\,000\,000)

The dominoes are not necessarily given in order of position.

Output

Print on the first line the minimum number of pushes needed to topple every domino.