#P3299. [SDOI2013] 保护出题人

[SDOI2013] 保护出题人

Description

The problem setter Mingming felt that making problems for SDOI2012 was too scary because he would always be blamed, so he made problems again for SDOI2013.

The kids who participated in SDOI2012 released many zombies, trying to attack Mingming’s home. As a contestant of SDOI2013, you need to protect the problem setter Mingming.

Zombies approach along a single straight road. You need to place plants in front of Mingming’s door to attack the zombies, preventing them from reaching the house.

Level 1: a single zombie with HP a1a_1 starts uniformly approaching from x1x_1 meters away, and you place a plant with attack power y1y_1 points/second to defend. Level 2: based on the previous level, add a new zombie with HP a2a_2 to the front of the queue, at distance dd from the next zombie, and the front zombie starts uniformly approaching from x2x_2 meters away; you re-place a plant with attack power y2y_2 points/second. ... Level nn: there are nn zombies in total, adjacent zombies are dd meters apart, the front zombie has HP ana_n, the second has HP an1a_{n-1}, and so on. The front zombie starts uniformly approaching from xnx_n meters away, and the other zombies follow while approaching at the same time. You re-place a plant with attack power yny_n points/second.

Each zombie moves in a straight line at speed 11 m/s. Since the plants’ firing speed is much higher than the zombies’ movement speed, the bullet travel time in the air can be ignored. All zombies appear and start approaching at the same time. Therefore, when one zombie dies, the next zombie immediately starts taking damage from the plant.

The game score depends on the total attack power you place, i=1nyi\sum \limits _{i=1} ^{n} y_i. The smaller the sum, the higher the score. To pursue the best possible score, you should place plants with the smallest possible attack power at every level.

As a contestant of SDOI2013, can you protect the problem setter?

Input Format

The first line contains two space-separated positive integers nn and dd, representing the number of levels and the distance between adjacent zombies.

The next nn lines each contain two space-separated positive integers. The (i+1)(i+1)-th line contains AiA_i and XiX_i, meaning that compared to the previous level, a new zombie with HP AiA_i is added to the front of the queue, and the front zombie starts approaching from a distance of XiX_i meters from the house.

Output Format

Output an integer: the minimal total attack power over the nn levels, rounded to the nearest integer.

5  2
3  3
1  1
10 8
4  8
2  3
7

Hint

Level 1: there is one zombie with HP 33 at distance 33 meters from the house, and the minimal plant attack power is 1.000001.00000.
Level 2: there is one zombie with HP 11 at 11 meter and one zombie with HP 33 at 33 meters, and the minimal plant attack power is 1.333331.33333.
Level 3: there is one zombie with HP 1010 at 88 meters, one with HP 11 at 1010 meters, and one with HP 33 at 1212 meters, and the minimal plant attack power is 1.250001.25000.
Level 4: there is one zombie with HP 44 at 88 meters, one with HP 1010 at 1010 meters, one with HP 11 at 1212 meters, and one with HP 33 at 1414 meters, and the minimal plant attack power is 1.400001.40000.
Level 5: there is one zombie with HP 22 at 33 meters, one with HP 44 at 55 meters, one with HP 1010 at 77 meters, one with HP 11 at 99 meters, and one with HP 33 at 1111 meters, and the minimal plant attack power is 2.285712.28571.
The minimal total plant attack power is 7.269057.26905.

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 1d,x,a10121 \le d, x, a \le 10^{12}.

Translated by ChatGPT 5