Skip to content

Commit 5c64064

Browse files
committed
Maximum number power puff girls with given ingredients
1 parent 83ab33a commit 5c64064

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"""
2+
Professor Utonium is restless because of the increasing crime in the world.
3+
The number of villains and their activities has increased to a great
4+
extent. The current trio of Powerpuff Girls is not well to fight the evils
5+
of the whole world. Professor has decided to create the maximum number of
6+
Powerpuff Girls with the ingredients he has.
7+
8+
9+
There are N ingredients required in a certain quantity to create a
10+
Powerpuff Girl. Professor has all the N ingredients in his laboratory and
11+
knows the quantity of each available ingredient. He also knows the
12+
quantity of a particular ingredient required to create a Powerpuff Girl.
13+
Professor is busy with the preparations and wants to start asap.
14+
15+
16+
17+
The villains, on the other hand, want to destroy the laboratory and stop
18+
Professor Utonium from creating more Powerpuff girls. Mojo Jojo is coming
19+
prepared with ammunition and Him is leading other villains like Princess,
20+
Amoeba Boys, Sedusa, Gangreen Gang etc.
21+
22+
Professor does not have much time as villains will reach the laboratory
23+
soon. He is starting the process but does not know the number of Powerpuff
24+
Girls which will be created. He needs your help in determining the maximum
25+
number of Powerpuff Girls which will be created with the current quantity
26+
of ingredients.
27+
28+
29+
30+
Example:
31+
32+
Professor Utonium requires 3 ingredients to make Powerpuff Girls. The 3
33+
ingredients are present in the laboratory in the given quantity:
34+
Ingredient A: 10
35+
Ingredient B: 20
36+
Ingredient C: 30
37+
38+
To make a Powerpuff Girl, Professor Utonium requires:
39+
3 units of Ingredient A
40+
6 units of Ingredient B
41+
10 units of Ingredient C
42+
43+
The maximum number of Powerpuff Girls which can be created are 3 as
44+
after 3, Professor will run out of Ingredient C.
45+
46+
Can you determine the maximum number?
47+
48+
49+
50+
Input Format
51+
The first line of input consists of the number of ingredients, N
52+
53+
The second line of input consists of the N space-separated integers
54+
representing the quantity of each ingredient required to create a
55+
Powerpuff Girl.
56+
57+
58+
The third line of input consists of the N space-separated integers
59+
representing the quantity of each ingredient present in the laboratory.
60+
61+
62+
63+
Constraints
64+
1<= N <=10000000 (1e7)
65+
66+
0<= Quantity_of_ingredient <= LLONG_MAX
67+
68+
69+
70+
Output Format
71+
Print the required output in a separate line.
72+
73+
Sample TestCase 1
74+
Input
75+
4
76+
2 5 6 3
77+
20 40 90 50
78+
Output
79+
8
80+
"""
81+
82+
def maxPowerPuffGirls(N,arrA,arrB):
83+
arr1 = arrA.copy()
84+
arr2 = arrB.copy()
85+
maxnum = 0
86+
while True:
87+
checker = []
88+
for i in range(N):
89+
if ((arr2[i] - arr1[i]) >= 0):
90+
arr2[i] -= arr1[i]
91+
checker.append(True)
92+
else:
93+
checker.append(False)
94+
if (True in checker) and (False not in checker):
95+
maxnum += 1
96+
if False in checker:
97+
break
98+
return maxnum
99+
100+
101+
if __name__ == '__main__':
102+
N = int(input())
103+
arrA = list(map(int,input().strip().split()))
104+
arrB = list(map(int,input().strip().split()))
105+
print (maxPowerPuffGirls(N,arrA,arrB))

0 commit comments

Comments
 (0)