## COCI '07 Regional #3 Kuhar

View as PDF

Points: 12
Time limit: 0.6s
Memory limit: 32M

Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Lisa works as a waitress in a restaurant. Tonight is her birthday so Lisa asked the chef to prepare his special meal for her friends. The chef's meal is made of ingredients. To prepare one serving of the meal he needs a certain amount of each ingredient.

There are some ingredients already available in the kitchen and Lisa will buy the rest at the grocery store. The store has all the necessary ingredients, each coming in smaller and larger packages. Lisa has dollars and wants to spend them so that the chef can make the most servings of his meal.

#### Input Specification

The first line contains two integers and , , .

Each of the following lines contains positive integers, information about one ingredient. These specify, in order:

• , , the amount of the ingredient needed in one serving;
• , , the amount of the ingredient already available in the kitchen;
• , , the size of the smaller package at the store;
• , , the price of the smaller package;
• , , the size of the larger package; and
• , , the price of the larger package.

#### Output Specification

Output the largest number of servings the chef can make if Lisa spends her money wisely.

#### Sample Input 1

2 100
10 8 10 10 13 11
12 20 6 10 17 24

#### Sample Output 1

5

#### Sample Input 2

3 65
10 5 7 10 13 14
10 5 8 11 14 15
10 5 9 12 15 16

#### Sample Output 2

2

In the first example, for dollars Lisa will buy three smaller and one larger package of the first ingredient, as well as one smaller and two larger packages of the second ingredient .

The chef will then have units of the first ingredient and units of the second ingredient, enough for servings.

## Comments

There are no comments at the moment.