Techgig code gladiators 2020 solutions - I | Python Practice
Problem statement:
The Powerpuff Girls
Professor Utonium is restless because of the increasing crime in the world. The number of villains and their activities has increased to a great extent. The current trio of Powerpuff Girls is not well to fight the evils of the whole world. Professor has decided to create the maximum number of Powerpuff Girls with the ingredients he has.
There are N ingredients required in a certain quantity to create a Powerpuff Girl. Professor has all the N ingredients in his laboratory and knows the quantity of each available ingredient. He also knows the quantity of a particular ingredient required to create a Powerpuff Girl. The professor is busy with the preparations and wants to start asap.
The villains, on the other hand, want to destroy the laboratory and stop Professor Utonium from creating more Powerpuff girls. Mojo Jojo is coming prepared with ammunition and Him is leading other villains like Princess, Amoeba Boys, Sedusa, Gangreen Gang, etc.
Professor does not have much time as villains will reach the laboratory soon. He is starting the process but does not know the number of Powerpuff Girls which will be created. He needs your help in determining the maximum number of Powerpuff Girls which will be created with the current quantity of ingredients.
Example:
Professor Utonium requires 3 ingredients to make Powerpuff Girls. The 3 ingredients are present in the laboratory in the given quantity:
To make a Powerpuff Girl, Professor Utonium requires:
3 units of Ingredient A
6 units of Ingredient B
10 units of Ingredient C
The maximum number of Powerpuff Girls that can be created is 3 as, after 3, Professor will run out of Ingredient C.
Can you determine the maximum number?
How to solve this problem
Explanation of the problem statements
Input Format
The first line of input consists of the number of ingredients, N
The second line of input consists of the N space-separated integers representing the quantity of each ingredient required to create a Powerpuff Girl.
The third line of input consists of the N space-separated integers representing the quantity of each ingredient present in the laboratory.
Constraints
1<= N <=10000000 (1e7)
0<= Quantity_of_ingredient <= MAX
Output Format
Print the required output in a separate line.Steps to solve the problem in python
Solution:
In Python3 and JAVA8
In Python3:
def main(): num=int(input()) r=list(map(int,input().split())) q=list(map(int,input().split())) lists=[ ] for i in range(num): sums=q[i]//r[i] lists.append(sums) print(min(lists)) main() #Made by Ankur Patel. |
In JAVA8:
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int ingredients = Integer.valueOf(reader.readLine()); String[] requireIngredients = reader.readLine().split(" "); String[] availableIngredients = reader.readLine().split(" "); Integer[] output = new Integer[ingredients]; for (int i = 0; i < ingredients; i++) { output[i] = Integer.valueOf(availableIngredients[i]) / Integer.valueOf(requireIngredients[i]); } Arrays.sort(output); System.out.println(output[0]); //Made by Ankur Patel |
If you have a better solution or query, please share in comment or Email.