比赛 |
20101025 |
评测结果 |
AAAAAAAAAA |
题目名称 |
买票 |
最终得分 |
100 |
用户昵称 |
.Xmz |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2010-10-25 19:26:31 |
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int a[1000001],ans,n,f,now,nown;
int main()
{
freopen("tickets.in","r",stdin);
freopen("tickets.out","w",stdout);
scanf("%d%d",&n,&f);
for (int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
int i=1,j=1;
while (j<=n)
{
if (i==j && a[i]>=f) i++,j++;
else if (now+a[j]<=f) now+=a[j],nown++,j++;
else {
if (ans<nown) ans=nown;
now-=a[i];
nown--;
i++;
}
}
printf("%d\n",ans);
return 0;
}