题解 | #未排序正数数组中累加和为给定值的最长子数组的长度#
未排序正数数组中累加和为给定值的最长子数组的长度
http://www.nowcoder.com/practice/a4e34287fa1b41f9bd41f957efbd5dff
while True: try: n,k = map(int,input().split()) ll = list(map(int,input().split())) res,tmp = 0,0 left,right = 0,0 while left < n: if tmp < k: if right < n: tmp += ll[right] right += 1 else: break else: if tmp == k: res = max(res,right-left) tmp -= ll[left] left += 1 print(res) except EOFError: break