A9789 | Clique Problem
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains the integer $n$ ( $1<=n<=200000$ ) — the number of points.
Each of the next $n$ lines contains two numbers $x_{i}$ , $w_{i}$ ( $0<=x_{i}<=10^{9},1<=w_{i}<=10^{9}$ ) — the coordinate and the weight of a point. All $x_{i}$ are different.
Each of the next $n$ lines contains two numbers $x_{i}$ , $w_{i}$ ( $0<=x_{i}<=10^{9},1<=w_{i}<=10^{9}$ ) — the coordinate and the weight of a point. All $x_{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.

The picture for the sample test.

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted