#BS0000466. Tối ưu năng lực sản xuất (Sensor Optimization Dilemma 2)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tối ưu năng lực sản xuất (Sensor Optimization Dilemma 2)
Sensor Optimization Dilemma 2
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A production line has stages. At stage , a unit of type S provides daily capacity at cost , and type T provides at cost . Any nonnegative integer number of units may be bought. The line capacity is the minimum of the stage capacities. Maximize it without exceeding budget .
Input
The first line contains . The next lines contain , respectively.
Output
Print the maximum capacity as an integer.
Subtasks
- Subtask 1 (20 points): ; ; ; ().
- Subtask 2 (30 points): ; ; ; ().
- Subtask 3 (50 points): ; ; ; ().
Examples
Example 1
Input
3 22
2 5 3 6
1 1 3 3
1 3 2 4
Output
4
Explanation
Buy two S units, one S plus one T, and two T units, respectively. Cost is 22 and every capacity is 4. Capacity 5 needs at least 27.
Example 2
Input
1 10000000
100 1 100 1
Output
1000000000
Explanation
Buy machines at unit cost 1 and capacity 100.
Example 3
Input
1 1
1 10000000 1 10000000
Output
0
Explanation
No machine is affordable.
Example 4
Input
10 7654321
8 6 9 1
5 6 4 3
2 4 7 9
7 8 9 1
7 9 1 6
4 8 9 1
2 2 8 9
1 6 2 6
4 2 3 4
6 6 5 2
Output
894742
Explanation
Capacity 894742 is affordable, but increasing it by one is not.