import java.util.*;
public class Main{
static int N;
static long S;
static long[] sum=new long[1000001];
public static boolean check(int n){
long tmp=0;
for(int i=1;i+2*n-1<=N;i++){
if((sum[i+n-1]-sum[i-1])>S || (sum[i+2*n-1]-sum[i+n-1])>S) continue;
return true;
}
return false;
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
N=sc.nextInt();
S=sc.nextLong();
for(int i=1;i<=N;i++) {
sum[i]=sum[i-1]+sc.nextInt();
}
int L=1,R=1000000;
while(L<R){
int middle=(L+R+1)/2;
if(check(middle)) L=middle;
else R=middle-1;
}
System.out.println(2*L);
}
}
最近在做蓝桥杯内存超限了我不知道哪里超限求解答