The manufacturing of a certain product requires N processes numbered 1,2,…,N. For each…
- User
The manufacturing of a certain product requires N processes numbered
1,2,…,N.
For each process i, there are two types of machines Si and
Ti available for purchase to handle it.
Machine
Si: Can process Ai products per day per unit, and costs Pi yen per unit. Machine Ti: Can process Bi products per day per unit, and costs
Qi yen per unit.
You can purchase any number of each machine, possibly zero.
Suppose that process i can handle Wi products per day as a result of introducing machines. Here, we define the production capacity as the minimum of W, that is,
i=1minNWi.
Given a total budget of
X yen, find the maximum achievable production capacity. Constraints
All input values are integers.
1≤N≤100 1≤Ai,Bi≤100
1≤Pi,Qi,X≤107
Input
The input is given from Standard Input in the following format:
N
X
A1
P1
B1
Q1
A2
P2
B2
Q2
⋮
AN
PN
BN
QN
Output
Print the answer as an integer. Sample Input 1 Copy
3 22 2 5 3 6 1 1 3 3 1 3 2 4
Sample Output 1 Copy
4
For example, by introducing machines as follows, we can achieve a production capacity of
4, which is the maximum possible.
For process
1, introduce 2 units of machine S1.
This allows processing
4 products per day and costs a total of
10 yen.
For process 2, introduce 1 unit of machine S2.
This allows processing
1 product per day and costs a total of
1 yen.
For process 2, introduce 1 unit of machine T2.
This allows processing
3 products per day and costs a total of
3 yen.
For process 3, introduce 2 units of machine T3.
This allows processing
4 products per day and costs a total of
8 yen.Sample Input 2 Copy
1 10000000 100 1 100 1
Sample Output 2 Copy
1000000000
Sample Input 3 Copy
1 1 1 10000000 1 10000000
Sample Output 3 Copy
0
There may be cases where a positive production capacity cannot be achieved. Sample Input 4 Copy
- Assistant