统计加二分查找。。
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main()
{
int n, t, a[100005], ans;
while(~scanf("%d %d", &n, &t))
{
a[0] = 0;
ans = 0;
for(int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
a[i] += a[i-1];
}
for(int i = 0; i < n; i++)
{
int left = i+1;
int right = n;
while(left <= right)
{
int mid = (left + right) / 2;
if(a[mid] - a[i] <= t)
{
left = mid + 1;
}
else
{
right = mid - 1;
}
}
ans = max(left - i, ans);
}
printf("%d\n", ans-1);
}
return 0;
}