CF607A.Chain Reaction
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n beacons located at distinct positions on a number line. The i -th beacon has position ai and power level bi . When the i -th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance bi 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 ai and bi ( 0<=ai<=1000000 , 1<=bi<=1000000 ) — the position and power level of the i -th beacon respectively. No two beacons will have the same position, so ai=aj 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 .