Nei subtask ci sono alcuni risultati che vengono bene, altri sono errati, mentre in altri va fuori tempo.
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
static FILE *fr, *fw;
static int N;
static long long M;
static int* V;
static int B;
int quadri(int N, long long M, int* V)
{
int risp=0;
B=1;
int G=0;
int i=0;
while(i<N-B+1&&B<=N)
{
int costo=0;
for(int j=0;j<B;j++)
{
costo=V[i+j]+costo;
}
if(costo<M)
{
G=G+1;
}
costo=0;
i++;
if(G==N-B+1)
{
risp=B;
G=0;
i=0;
B++;
}
}
return risp;
}
int main() {
fr = stdin;
fw = stdout;
int i0;
fscanf(fr, "%d %lld", &N, &M);
V = (int*)malloc(N * sizeof(int));
for (i0 = 0; i0 < N; i0++) {
fscanf(fr, "%d", &V[i0]);
}
B = quadri(N, M, V);
fprintf(fw, "%d\n", B);
fclose(fr);
fclose(fw);
return 0;
}