WC '17 Contest 2 J2 - Breeding an Army

View as PDF

Submit solution


Points: 3
Time limit: 1.0s
Memory limit: 16M

Author:
Problem types
Woburn Challenge 2017-18 Round 2 - Junior Division

The evil wizard Saruman is breeding himself an army of fearsome Uruk-hai soldiers. Each Uruk-hai can be created out of M_u men, O_u orcs, and L_u litres of mud (1 \le M_u, O_u, L_u \le 1\,000).

Saruman has at his disposal M_s men, O_s orcs, and L_s litres of mud (1 \le M_s, O_s, L_s \le 1\,000).

What's the maximum number of Uruk-hai that Saruman can create without exceeding his resources?

Input Specification

The first line of input consists of three space-separated integers, M_u, O_u, and L_u.
The next line consists of three space-separated integers, M_s, O_s, and L_s.

Output Specification

Output a single integer, the maximum number of Uruk-hai that can be created.

Sample Input

1 4 3
8 14 10

Sample Output

3

Sample Explanation

Creating 3 Uruk-hai requires 3 men, 12 orcs, and 9 litres of mud, which doesn't exceed Saruman's resources. However, he would not be able to create 4 Uruk-hai.


Comments

There are no comments at the moment.