#P16695. [CSPro 29] 垦田计划
[CSPro 29] 垦田计划
Background
Luogu’s testdata is for community communication only and is not official testdata. Official judging link: https://www.cspro.org/.
Problem Description
Dundun selected a total of regions to reclaim into farmland. Since the regions have different sizes, the time needed to reclaim them is also different. It is estimated that the reclamation time of region () is days. These regions can be reclaimed at the same time, so the total time depends on the region that takes the longest time, namely:
$$\begin{aligned} t_{Total} = \max\{t_1, t_2, \cdots, t_n\} \end{aligned}$$To speed up the progress, Dundun plans to invest extra resources in some regions to reduce the reclamation time. Specifically:
- For region , every time you invest units of resources, you can reduce its reclamation time by day.
- The number of days reduced must be an integer, meaning the amount of resources invested in region must be an integer multiple of .
- For region , you can invest at most units of resources to reduce its reclamation time to days.
- Here, is the minimum number of days to reclaim one region, satisfying . In other words, if resources were unlimited, all regions could be reclaimed in days.
Now Dundun has a total of units of resources available. Compute the minimum number of days needed to reclaim all regions.
Input Format
Read input from standard input.
There are lines in total.
The first line contains three positive integers , , and separated by spaces, representing the total number of regions to be reclaimed, the amount of resources Dundun has, and the minimum reclamation days for each region.
The next lines each contain two positive integers and separated by spaces, representing the reclamation time of region and the amount of resources needed to reduce the time by day.
Output Format
Write output to standard output.
Output one integer, representing the minimum total time to reclaim the regions.
4 9 2
6 1
5 1
6 2
7 1
5
4 30 2
6 1
5 1
6 2
7 1
2
Hint
Explanation for Sample 1
As shown in the table below, investing units of resources can reduce the total time to days. At this point, Dundun still has units of resources left, but no matter how they are allocated, the total time cannot be reduced further.
| Base time | Resources needed to reduce day | Resources invested | Actual time | |
|---|---|---|---|---|
| ^ | ^ | |||
| ^ | ||||
Explanation for Sample 2
By investing units of resources, you can reduce the reclamation time of all regions to exactly days. Due to the limit , the remaining units of resources cannot reduce the time any further.
Subtasks
of the testdata satisfies: and .
All testdata satisfies: and .
Translated by ChatGPT 5