Due to the low constraints of the problem, we can iterate through every possible photo.
Implementation
Time Complexity:
n = int(input())flowers = list(map(int, input().split()))valid_photos = 0for i in range(n):for j in range(i, n):# find the average petal # in the range i - javg_petals = sum(flowers[i : j + 1]) / (j - i + 1)for index in range(i, j + 1):
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!