#P6508. [CRCI2007-2008] KUHAR
[CRCI2007-2008] KUHAR
Problem Description
To cook a certain dish, you need kinds of ingredients. For the -th ingredient, one dish requires units, and the kitchen currently has units. For each ingredient, you can buy more from the supermarket. There are two package types: small and large. For the -th ingredient, a small package contains units and costs yuan per package; a large package contains units and costs yuan per package. For each ingredient, you may buy any number (possibly zero) of small and large packages.
You have yuan. Find the maximum number of dishes you can cook with this money.
Input Format
The first line contains two integers: the number of ingredients and the amount of money .
Lines to each contain six integers. Line contains , with meanings as described in the Description.
Output Format
Output one integer in a single line, the maximum number of dishes you can cook.
2 100
10 8 10 10 13 11
12 20 6 10 17 24
5
3 65
10 5 7 10 13 14
10 5 8 11 14 15
10 5 9 12 15 16
2
Hint
Constraints
For all testdata, it is guaranteed that:
- , .
- , .
- , .
Notes
This problem is translated from COCI2007-2008 Regional Competition T3 KUHAR。
Translated by ChatGPT 5