CF527D.Clique Problem
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
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 G. It is required to find a subset of vertices C of the maximum size such that any two of them are connected by an edge in graph G. 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 n distinct points on a line. Let the i-th point have the coordinate x__i and weight w__i. Let's form graph G, whose vertices are these points and edges connect exactly the pairs of points (i, j), such that the distance between them is not less than the sum of their weights, or more formally: |x__i - x__j| ≥ w__i + w__j.
Find the size of the maximum clique in such graph.
团问题(Clique Problem)是最著名的 NP 完全问题之一。在某些简化条件下,其可表述如下:给定一个无向图 G,要求找出一个顶点子集 C,使得其中任意两个顶点在图 G 中均通过一条边相连,并且该子集的大小尽可能大。听起来很简单,对吧?然而,目前尚无人发现能在图规模的多项式时间内求解该问题的算法。不过,与许多其他 NP 完全问题类似,若考虑某一特定类型的图,团问题会变得更容易求解。
考虑直线上互不重合的 n 个点。设第 i 个点的坐标为 xi,权重为 wi。我们构造图 G:其顶点即为这些点;而两点 (i,j) 之间存在一条边,当且仅当它们之间的距离不小于它们权重之和,即更形式化地表示为:
∣xi−xj∣≥wi+wj.
请计算该图中最大团的大小。
输入格式
The first line contains the integer n (1 ≤ n ≤ 200 000) — the number of points.
Each of the next n lines contains two numbers x__i, w__i (0 ≤ x__i ≤ 109, 1 ≤ w__i ≤ 109) — the coordinate and the weight of a point. All x__i are different.
第一行包含一个整数 n(1≤n≤200000)—— 点的数量。
接下来的 n 行中,每行包含两个数 xi、wi(0≤xi≤109,1≤wi≤109)—— 分别表示一个点的坐标和权重。所有 xi 均互不相同。
输出格式
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.

如果你恰好知道如何在不利用题目陈述中所给出的图的特定性质的情况下解决此问题,那么你将获得一百万美元的奖金!
样例测试的图片。

输入解题思路,AI测评打分。不知道怎么写?