luogu#P9350. [JOI 2023 Final] Advertisement 2
[JOI 2023 Final] Advertisement 2
题目描述
There are residents in JOI Kingdom, numbered from to . Resident () lives at the coordinate on the real line, and its power of influence is . It may be the case that more than one residents live at the same coordinate. A resident with a large power of influence has a high advertising potential. But such a resident is careful in buying books.
Rie published a book on informatics. In order to encourage many people to buy copies of the book, she can donate copies of the book to some residents. If she donates a copy of the book to Resident (), Resident will get a copy of Rie’s book. Moreover, among the residents who did not yet get copies of the book, every resident () satisfying the following condition will buy a copy of the book and get it.
- The distance between Resident and Resident on the real line is less than or equal to . In other words, is satisfied.
If all the residents read Rie’s book, the Olympiads in Informatics will be greatly recognized. Write a program which calculates the minimum number of residents who will be donated copies of Rie’s book so that all the residents in JOI Kingdom will get copies of Rie’s book.
输入格式
Read the following data from the standard input.
输出格式
Write one line to the standard output. The output should contain the minimum number of residents who will be donated copies of Rie’s book.
题目大意
JOI 王国有 位居民,从 到 编号。居民 ()居住在数轴上坐标 处,其影响力为 。同一个坐标可能住了多于一位居民。居民的影响力越高,广告效应也越高,但买书也越谨慎。
Rie 出版了一本关于信息学的书。为了让更多人购买这本书,她可以给一些居民送书。如果她给居民 ()送了一本书,除了居民 将得到一本 Rie 的书外,在还没有得到这本书的居民中,每一个满足以下条件的居民 ()都会购买这本书:
- 居民 和 居民 在数轴上的距离小于或等于 。换句话说, 成立。
如果所有的居民都读了 Rie 的书,信息学竞赛将得到极大的认可。请写一个程序,计算 Rie 最少将书赠送给多少位居民,就可以让 JOI 王国的所有居民都会得到 Rie 的书。
4
4 2
2 3
3 4
6 5
2
3
7 10
10 10
7 10
2
10
31447678 204745778
430226982 292647686
327782937 367372305
843320852 822224390
687565054 738216211
970840050 766211141
563662348 742939240
103739645 854320982
294864525 601612333
375952316 469655019
5
提示
Samples
Sample 1
For example, if Rie donates copies of the book in the following way, all the residents in JOI Kingdom will get copies of Rie’s book.
- Rie donates a copy of the book to Resident 3.
- Since and , Resident 1 will buy a copy of Rie’s book and get it.
- Since and , Resident 2 will buy a copy of Rie’s book and get it.
- Since and , Resident 4 will not buy a copy of Rie’s book. Therefore, Residents 1, 2, 3 will get copies of Rie’s book.
- Rie donates a copy of the book to Resident 4. Since all the residents except Resident 4 already got copies of Rie’s book, all the residents in JOI Kingdom finally get copies of Rie’s book.
Since it is impossible to donate copies of the book to less than two residents so that all the residents in JOI Kingdom will get copies of Rie’s book, output 2.
This sample input satisfies the constraints of Subtasks 2, 3, 4.
Sample 2
This sample input satisfies the constraints of all the subtasks.
Sample 3
This sample input satisfies the constraints of Subtasks 2, 3, 4.
Constraints
- .
- ().
- ().
- Given values are all integers.
Subtasks
- (10 points) .
- (23 points) .
- (36 points) .
- (31 points) No additional constraints.