luogu#P5094. [USACO04OPEN] MooFest G 加强版
[USACO04OPEN] MooFest G 加强版
Problem Description
Every year, John’s cows take part in the MooFest, a big festival for cows all over the world. The festival has many fun activities, such as haystack piling contests and cow-pen jumping contests. Sometimes the cows also poke each other for fun. Of course, they will line up and moo loudly to celebrate their holiday.
The cows’ moos are so noisy that each cow’s hearing is damaged to a different degree. Now you are given cow ’s hearing level . This means that if cow wants to say something that cow can hear, cow must use a volume greater than . Therefore, if cows and want to talk to each other, their volume must be at least , where is the distance between them.
Now the cows are standing on a straight line, and each cow has a coordinate . If every pair of cows is talking, and each pair uses the minimum required volume, what is the sum of the volumes over all pairs?
Input Format
The first line contains an integer .
The next lines each contain two numbers and , representing the -th cow’s hearing level and coordinate, respectively.
Output Format
Output one number, which is the sum of the volumes when these pairs of cows talk.
4
3 1
2 5
2 6
4 3
57
Hint
Constraints
Since an algorithm can pass under the original data, some additional enhanced testdata has been added.
The original data is Subtask , and the newly added data is Subtask .
- Subtask ( point): .
- Subtask ( points): .
Translated by ChatGPT 5