class Solution:
def solve(self, weights, values, capacity):
res = 0
for pair in sorted(zip(weights, values), key=lambda x: - x[1]/x[0]):
if not bool(capacity):
break
if pair[0] > capacity:
res += int(pair[1] / (pair[0] / capacity))
capacity = 0
elif pair[0] <= capacity:
res += pair[1]
capacity -= pair[0]
return int(res)
ob = Solution()
weights = [int(i) for i in input().split()]
values = [int(i) for i in input().split()]
capacity = int(input())
print("Maximum profit is : " + str(ob.solve(weights, values, capacity)))
To embed this program on your website, copy the following code and paste it into your website's HTML: