#P10098. [ROIR 2023] 地铁建设 (Day 2)
[ROIR 2023] 地铁建设 (Day 2)
Background
Translated from ROIR 2023 D2T1.
A shield tunneling machine used to build subway tunnels has motors. All motors are connected in parallel, so the voltage across all motors is the same.
Each motor has two modes. Suppose the voltage received by all motors is . Then, for the -th motor, if , it works in the first mode; otherwise, it works in the second mode.
The unit current of the -th motor is in the first mode and in the second mode. Therefore, by , when the motor is in the first mode, each increase of unit of voltage increases its power by units; when it is in the second mode, each increase of unit of voltage increases its power by units. In other words, when the voltage is , if the -th motor is in the first mode, it runs at power ; if it is in the second mode, it runs at power .
Problem Description
What is the minimum voltage that must be provided (the voltage must be an integer) so that the total power of all motors is greater than or equal to ?
Input Format
The first line contains two integers and .
The next lines each contain three integers .
Output Format
Output one integer, the minimum voltage.
1 6
4 1 2
5
3 15
2 3 3
4 2 1
5 2 2
3
Hint
This problem uses bundled testdata.
| Subtask ID | Points | Special Property |
|---|---|---|
| All are equal | ||
For of the data, , , , .
Translated by ChatGPT 5