The function accepts two positive integers ‘r’ and ‘unit’ and a positive integer array ‘arr’ of size ‘n’ as its argument ‘r’ represents the number of rats present in an area, ‘unit’ is the amount of food each rat consumes and each ith element of array ‘arr’ represents the amount of food present in ‘i+1’ house number, where 0 <= i
Answers
Answered by
4
Answer:
i dont the answer pleasr acept my aproval
Answered by
0
Explanation:
def task(r, unit, arr):
n = len(arr)
sum = r * unit
sum_arr = 0
for i in arr:
sum_arr = sum_arr + i
if len(arr) == 0:
return -1
elif sum > sum_arr:
return 0
elif sum < sum_arr:
return 1
task(7,2,[2, 8, 3, 5, 7, 4, 1, 2])
1
Input:
r: 7
unit: 2
n: 8
arr: 2 8 3 5 7 4 1 2
Similar questions