303114: CF607A. Chain Reaction

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Chain Reaction

题意翻译

有n个激光塔排成一行,第i个激光塔的位置为ai,威力是bi,当第i个激光塔被激活后,所有在这个激光塔左边且与该激光塔距离小于等于bi的激光塔都会被摧毁,而该激光塔本身不会受到伤害。管理员从右向左依次激活每个激光塔,如果一个激光塔被摧毁了,则它无法被激活。 现在管理员想让你帮他一个忙,管理员决定在现有的n个激光塔的右边再放一个激光塔,这个激光塔的位置和威力是任意的(但必须在现有激光塔的右边)。管理员从这个新加入的激光塔开始从右到左依次激活每个激光塔,现在他想要知道,怎么安排这个新激光塔,可以使得被摧毁的激光塔的总数最少。

题目描述

There are $ n $ beacons located at distinct positions on a number line. The $ i $ -th beacon has position $ a_{i} $ and power level $ b_{i} $ . When the $ i $ -th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance $ b_{i} $ inclusive. The beacon itself is not destroyed however. Saitama will activate the beacons one at a time from right to left. If a beacon is destroyed, it cannot be activated. Saitama wants Genos to add a beacon strictly to the right of all the existing beacons, with any position and any power level, such that the least possible number of beacons are destroyed. Note that Genos's placement of the beacon means it will be the first beacon activated. Help Genos by finding the minimum number of beacons that could be destroyed.

输入输出格式

输入格式


The first line of input contains a single integer $ n $ ( $ 1<=n<=100000 $ ) — the initial number of beacons. The $ i $ -th of next $ n $ lines contains two integers $ a_{i} $ and $ b_{i} $ ( $ 0<=a_{i}<=1000000 $ , $ 1<=b_{i}<=1000000 $ ) — the position and power level of the $ i $ -th beacon respectively. No two beacons will have the same position, so $ a_{i}≠a_{j} $ if $ i≠j $ .

输出格式


Print a single integer — the minimum number of beacons that could be destroyed if exactly one beacon is added.

输入输出样例

输入样例 #1

4
1 9
3 1
6 1
7 4

输出样例 #1

1

输入样例 #2

7
1 1
2 1
3 1
4 1
5 1
6 1
7 1

输出样例 #2

3

说明

For the first sample case, the minimum number of beacons destroyed is $ 1 $ . One way to achieve this is to place a beacon at position $ 9 $ with power level $ 2 $ . For the second sample case, the minimum number of beacons destroyed is $ 3 $ . One way to achieve this is to place a beacon at position $ 1337 $ with power level $ 42 $ .

Input

题意翻译

有 $n$ 个激光塔排成一行,第 $i$ 个激光塔的位置为 $a_i$ ,威力是 $b_i$ 当第 $i$ 个激光塔被激活后,对于任意其他激光塔 $j$ ,如果 $0 < a_i-a_j \le b_i$ ,则激光塔 $j$ 被摧毁。 添加一个新激光塔 $k$ ,使 $a_k > \text{max}\{a_1,a_2, ... ,a_n\}$ 管理员现在开始开始从右到左依次激活每个激光塔,如果一个激光塔被摧毁了,那就不激活。 请调整 $a_k$ 和 $b_k$ ,使被摧毁的激光塔总数最少。

加入题单

算法标签: