君はまるで砂漠に咲く、一輪の花。

僕はその花に引き寄せられる蝶。

Codeforces Round #171 (Div. 2)

はい。
http://codeforces.com/contest/279

B. Books

ざっくりと大意

・n冊の本があり、読了するのにそれぞれ\(a_i\)掛かる ・自由な時間tを使って連続した本を読む 読むことの出来る最も多くの本は何冊か??

方針のようなもの

・先頭からしゃくとり法っぽく sumやlenは使うと遅くなるので別途変数で

n,t=map(int,raw_input().split())
l=[int(x) for x in raw_input().split()]
ans=chk=0
b=h=s=0
for i in xrange(len(l)):
    s+=l[i]
    chk+=1
    if s>t:
        while 1:
            if s<=t:
                break
            else:
                s-=l[b]
                b+=1
                chk-=1
    ans=max(ans, chk)
print ans