43222023-03-24 12:55:28PallanekPéterLeghosszabb nyaralás (75 pont)python3Accepted 75/75133ms33732 KiB
N,P=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
a=0; b=0; ossz=0; db=0; mx=0
while b<N:
    if ossz>P:
        ossz-=A[a]
        db-=1
        a+=1
    else:
        ossz+=A[b]
        db+=1
        b+=1
    if db>mx and ossz<=P:
        mx=db
print(mx)
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/017ms10924 KiB
2Accepted0/0133ms32520 KiB
3Accepted3/317ms11608 KiB
4Accepted3/317ms11492 KiB
5Accepted3/317ms11740 KiB
6Accepted3/317ms12024 KiB
7Accepted3/317ms12156 KiB
8Accepted4/417ms12164 KiB
9Accepted4/417ms12328 KiB
10Accepted5/517ms12544 KiB
11Accepted5/527ms13536 KiB
12Accepted5/528ms14480 KiB
13Accepted7/793ms16952 KiB
14Accepted7/7118ms26304 KiB
15Accepted7/7127ms32940 KiB
16Accepted8/8115ms28400 KiB
17Accepted8/8130ms33732 KiB