B. Books

 此题直接暴力是要超的,,虽然数不大,但是也是头痛啊,,,最后成功简化。。。60Ms  AC。。。。。

 1 #include<stdio.h>
 2 #define N 100010
 3 
 4 int a[N];
 5 __int64 t,max,sum,count;
 6 int main ()
 7 {
 8     int i,j,n,strt;
 9     while(scanf("%d%I64d",&n,&t)!=EOF)
10     {
11         max=0;sum=0;count=0;
12         for(i=1;i<=n;i++)
13         {   
14             scanf("%d",&a[i]);
15             if(i==1)strt=1;
16             if((sum+=a[i])<=t){count++;}
17             else {sum-=a[strt];strt++;}
18             if(count>max){max=count;}
19             //printf("%d
",sum);
20         }
21         printf("%I64d
",max);
22     }
23 }
原文地址:https://www.cnblogs.com/ace-top/p/3288039.html