#P1800. software
software
Description
A software development company needs to develop two software products and deliver them at the same time. To finish this task as soon as possible, each software is divided into modules to be completed by the company’s technicians. For each technician, the number of days required to complete any module of the same software is the same and known, but the time to complete a module of the other software may be different. At any given moment, each technician can work on at most one module, and each module must be completed independently by exactly one person; collaboration on a single module is not allowed. During the entire development period, after finishing a module, a technician may proceed to any module of either software. Write a program to determine the earliest day on which the company can deliver the software.
Input Format
The first line contains two space-separated integers and , where , . Each of the next lines contains two space-separated integers and . Here, is the number of days this technician needs to complete one module of the first software, and is the number of days needed to complete one module of the second software, where .
Output Format
Output a single line containing an integer , indicating the earliest day after which the company can deliver the software.
3 20
1 1
2 4
1 6
18
Hint
Sample Explanation
The fastest plan is for the first technician to complete modules of the second software, taking days; the third technician completes modules of the first software, taking days; the remaining modules are completed by the second technician, taking days. Finishing all modules takes days. If the first technician completes modules of the second software and the third technician completes modules of the first software, and the remaining modules are completed by the second technician, it still takes days. Therefore, it is impossible to finish in fewer than days.
Translated by ChatGPT 5
京公网安备 11011102002149号