连续未排序定值最长子数组_python3
未排序正数数组中累加和为给定值的最长子数组的长度
http://www.nowcoder.com/questionTerminal/a4e34287fa1b41f9bd41f957efbd5dff
def solve(l, n, k): ans = s = i = j = 0 while i < n: if s < k: if j < n: s += l[j] j += 1 else: break else: if s == k: ans = max(ans, j - i) s -= l[i] i += 1 return ans n, k = map(int, input().split()) l = list(map(int, input().split())) print(solve(l, n, k))