All Tracks Math Problem

Fruit shop
Tag(s):

Math, Very-Easy

Problem
Editorial
Analytics

John loves fruits. He eats one apple, banana or pear literally every hour.

John came to fruit shop to buy some fruits. He has $$m$$ coins that he is going to spend to buy as many fruits as he can. He counted the number of apples, bananas and pears, and he also knows the price of a single apple, the price of a single banana and the price of a single pear in this shop.

Help John to buy the maximum number of fruits.

Input format

First line contains three integers $$a$$, $$b$$ and $$p$$ — the number of coins needed to be spend to buy one apple, one banana and one pear ($$1 \le a, b, p \le 100$$).

Second line contains three integers $$c_a$$, $$c_b$$ and $$c_p$$ — the number of apples, the number of bananas and the number of pears available in the store ($$1 \le c_a, c_b, c_p \le 100$$).

Third line contains integer $$m$$ — the number of coins John owns ($$1 \le m \le 30 000$$).

Output format

Output single integer — the maximum number of fruits John can buy.

SAMPLE INPUT
1 5 10
2 4 1
14
SAMPLE OUTPUT
4
Explanation

John buys two apples and two bananas, spending 12 coins.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala 2.11.8, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

November Easy '16

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications