This is a straight forward question. Joey has to eat all the food in the fridge. So just adding all the numbers gives the answer.
The solution will be accepted only if we use int for N and long long int for foodi.
This solution has a complexity of O(n).
AUTHOR’S AND TESTER’S SOLUTIONS:
Author’s solution can be found here.
Tester’s solution can be found here.