luogu#P5025. [SNOI2017] 炸弹

    ID: 4040 远端评测题 2500ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2017线段树各省省选陕西强连通分量

[SNOI2017] 炸弹

Problem Description

There are nn bombs on a straight line. The coordinate of each bomb is xix_i, and its explosion radius is rir_i. When a bomb explodes, if the position xjx_j of another bomb satisfies:
xjxiri|x_j-x_i| \le r_i, then that bomb will also be detonated.

Now, please help compute: if we detonate bomb ii first, how many bombs will be detonated in total?

The answer should be taken modulo 109+710^9 + 7.

Input Format

The first line contains an integer nn, representing the number of bombs.
Lines 2n+12 \sim n+1 each contain two integers, representing xix_i and rir_i. It is guaranteed that xix_i is strictly increasing.

Output Format

Output one integer, representing i=1ni×\sum \limits_{i=1}^n i\times the number of bombs that bomb ii can detonate.

4
1 1
5 1
6 5
15 15
32

Hint

Constraints
For 20%20\% of the testdata: n100n\leq 100.

For 50%50\% of the testdata: n1000n\leq 1000.

For 80%80\% of the testdata: n100000n\leq 100000.

For 100%100\% of the testdata: 1n5000001\le n\leq 500000, 1018xi1018-10^{18}\leq x_{i}\leq 10^{18}, 0ri2×10180\leq r_{i}\leq 2\times 10^{18}.

Translated by ChatGPT 5