Codeforces Round 336 (Div. 2)
C
Chain Reaction
Codeforces
未评级
原题
← BD →
翻译中…

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.

翻译中…

Input

翻译中…

The first line of input contains a single integer $*n*$ ($1 ≤ *n* ≤ 100 000$) — the initial number of beacons.

翻译中…

The $*i*$-th of next $*n*$ lines contains two integers $*a*_{*i*}$ and $*b*_{*i*}$ ($0 ≤ *a*_{*i*} ≤ 1 000 000$, $1 ≤ *b*_{*i*} ≤ 1 000 000$) — 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*$.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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 #1
4
1 9
3 1
6 1
7 4
Output #1
1
InputCopy OutputCopy
Input #2
7
1 1
2 1
3 1
4 1
5 1
6 1
7 1
Output #2
3
InputCopy OutputCopy
题目信息
题号
608C
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。