CF527D.Clique Problem

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph GG . It is required to find a subset of vertices CC of the maximum size such that any two of them are connected by an edge in graph GG . Sounds simple, doesn't it? Nobody yet knows an algorithm that finds a solution to this problem in polynomial time of the size of the graph. However, as with many other NP-complete problems, the clique problem is easier if you consider a specific type of a graph.

Consider nn distinct points on a line. Let the ii -th point have the coordinate xix_{i} and weight wiw_{i} . Let's form graph GG , whose vertices are these points and edges connect exactly the pairs of points (i,j)(i,j) , such that the distance between them is not less than the sum of their weights, or more formally: xixj>=wi+wj|x_{i}-x_{j}|>=w_{i}+w_{j} .

Find the size of the maximum clique in such graph.

输入格式

The first line contains the integer nn ( 1<=n<=2000001<=n<=200000 ) — the number of points.

Each of the next nn lines contains two numbers xix_{i} , wiw_{i} ( 0<=xi<=109,1<=wi<=1090<=x_{i}<=10^{9},1<=w_{i}<=10^{9} ) — the coordinate and the weight of a point. All xix_{i} are different.

输出格式

Print a single number — the number of vertexes in the maximum clique of the given graph.

输入输出样例

  • 输入#1

    4
    2 3
    3 1
    6 1
    0 2
    

    输出#1

    3
    

说明/提示

If you happen to know how to solve this problem without using the specific properties of the graph formulated in the problem statement, then you are able to get a prize of one million dollars!

The picture for the sample test.

首页