| 记录编号 | 
        469816 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        483.买票 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         liuyu | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.264 s  | 
    
    
        | 提交时间 | 
        2017-11-03 20:07:39 | 
        内存使用 | 
        4.13 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<bits/stdc++.h>
using namespace std;
int n,f,a[1000000+10],sum,l,len,ans;
int main(){
	freopen("tickets.in","r",stdin);
	freopen("tickets.out","w",stdout);
	ios::sync_with_stdio(false);
	cin>>n>>f;
	for(int i=1;i<=n;i++)cin>>a[i];
	len=l=1;sum=a[1];if(a[1]<=f)ans=1;
	for(int i=2;i<=n;i++){
		sum+=a[i];
		len++;
		while(sum>f&&l<=i){
			sum-=a[l];
			l++;
			len--;
		}
		ans=max(ans,len);
	}
	cout<<ans<<endl;
	return 0;
}