def task(r, unit, arr):
n = len(arr)
#We calculate the total amount of food that the rats can consume
sum = r * unit
sum_arr = 0
#We calculate the total amount in the households
for i in arr:
sum_arr = sum_arr + i
if len(arr) == 0:
return -1
elif sum > sum_arr:
return 0
#Where 1 represents that the household has surplus food for the rats
elif sum < sum_arr:
return 1
task(7,2,[2, 8, 3, 5, 7, 4, 1, 2])
1
Comments
Leave a comment