下面是我的代码:
n,x = map(int,input().split())
wide = n
a = [int(num) for num in input().split()]
wide = 1
sum = [0] * (n - 1)
sum[0] = a[0]
while wide < n - 1:
sum[wide] = sum[wide - 1] + a[wide]
wide += 1
def bisection(left,right):
return (left + right) // 2
def boolcheck(length):
for i in range(length, n - 1):
if sum[i] - sum[i - length] < 2 * x:
return 0
return 1
left = 1
right = n - 1
while left <= right:
mid = bisection(left,right)
if boolcheck(mid):
right = mid - 1
else:
left = mid + 1
print(left)