[ABC374E] 流水线产能上限 (Sensor Optimization Dilemma 2)
Problem Statement
The manufacturing of a certain product requires processes numbered .
For each process , there are two types of machines and available for purchase to handle it.
-
Machine : Can process products per day per unit, and costs yen per unit.
-
Machine : Can process products per day per unit, and costs yen per unit.
You can purchase any number of each machine, possibly zero.
Suppose that process can handle products per day as a result of introducing machines.
Here, we define the production capacity as the minimum of , that is, .
Given a total budget of yen, find the maximum achievable production capacity.
Input
The input is given from Standard Input in the following format:
$N$ $X$
$A_1$ $P_1$ $B_1$ $Q_1$
$A_2$ $P_2$ $B_2$ $Q_2$
$\vdots$
$A_N$ $P_N$ $B_N$ $Q_N$
Output
Print the answer as an integer.
Example
3 22
2 5 3 6
1 1 3 3
1 3 2 4
4
Note
-
Constraints:
-
All input values are integers.
-
-
-
-
Source: ABC374E