滑动窗口
# 求子序列最大平均数
def func(li: list, k: int):
sum = 0
n = len(li)
for i in range(k):
sum += li[i]
for i in range(k, n):
temp = sum + li[i] - li[k - i]
if temp > sum:
sum = temp
return sum / k
if __name__ == '__main__':
li = [1, 12, -5, -6, 50, 3]
k = 4
print(func(li, k))