记录编号 | 20451 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 买票 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.766 s | ||
提交时间 | 2010-10-26 08:48:26 | 内存使用 | 2.02 MiB | ||
program tickets(input,output); var a:array[1..1000000]of integer; n,f,p:longint; ans,head,i,j,z:longint; begin assign(input,'tickets.in'); reset(input); readln(n,f); for i:=1 to n do read(a[i]); close(input); p:=0; head:=1; for i:=1 to n do begin if a[i]+p<=f then begin p:=p+a[i]; inc(z); if z>ans then ans:=z; end else begin while (p+a[i]>f) do begin p:=p-a[head]; inc(head); dec(z); end; p:=p+a[i]; inc(z); if z>ans then ans:=z; end; end; assign(output,'tickets.out'); rewrite(output); writeln(ans); close(output); end.