#P4273. [NOI2004] 降雨量
[NOI2004] 降雨量
Description
Country M is very rainy, especially City P, where frequent rainfall causes trouble for people traveling. To help pedestrians cross the street on rainy days, the authorities have installed a device called the "automatic umbrella" above every crosswalk (see Figure 1).
Each automatic umbrella can be approximated as a rectangular board with negligible thickness. These umbrellas have excellent water absorption: any raindrops falling on them are completely absorbed by small holes on the top and carried away through pipes. When it is not raining, the umbrellas are idle. Once it starts raining, they immediately begin uniform linear back-and-forth motion: moving from one side of the road to the other at a fixed speed, then returning at the same speed, and repeating this cycle until the rain stops. At no time does an automatic umbrella cross the boundaries of the road. With these automatic umbrellas, pedestrians without umbrellas can walk under them in the rain without getting wet.
Since the umbrellas are of limited size, one umbrella is obviously not enough when many people need to use them to cross the road. Therefore, multiple automatic umbrellas are installed above several main crosswalks. The width of each umbrella equals the width of the crosswalk, their heights differ, their lengths may differ, and their speeds may also differ.
Given the detailed setup of a particular crosswalk, compute the total volume of rainwater that falls onto the crosswalk during the time interval from the start of the rain to seconds.
Input Format
The first line contains four integers , , , . Here, is the number of automatic umbrellas, is the width of the road, is the time duration (in seconds) from the start of the rain over which the rainfall is to be counted, and is the rainfall volume per unit area per unit time.
For clarity, consider the cross-section view of five umbrellas in the sky as shown in Figure 2. Take the left boundary of the road as the origin, the positive -axis to the right, and the positive -axis upward to set up a Cartesian coordinate system. In this way, each automatic umbrella can be viewed as a line segment in the plane.

Each of the next lines describes one automatic umbrella with three integers. The first number is the initial position, given by the -coordinate of its left endpoint. The second number is the length of the umbrella, i.e., its size in the direction. The third number is the umbrella’s velocity; the magnitude of is its speed. If , the umbrella initially moves to the right; if , it initially moves to the left; if , the umbrella is stationary.
Output Format
Output a single real number: the total volume of rainwater that falls onto the crosswalk from the start of the rain to time seconds. The answer should be rounded to two decimal places.
2 4 3 10
0 1 1
3 1 -1
65.00
Hint
Conventions
- Raindrops fall uniformly, straight down at a constant speed.
- Both the automatic umbrellas and the road are horizontal.
- The width of each automatic umbrella and the crosswalk are both equal to .
Constraints
- .
- .
- .
- .
- The total number of round trips among all umbrellas does not exceed ; one round trip is counted as going there and back.
Translated by ChatGPT 5
京公网安备 11011102002149号