113512024-08-21 19:19:5642Leghosszabb nyaralás (75 pont)python3Accepted 75/75111ms13528 KiB
from sys import stdin
input = stdin.readline

def main():
    N,P = map(int,input().split())
    A = list(map(int,input().split()))
    res=0
    i=j=0
    cur=0
    while j<N:
        if cur<P:
            cur+=A[j]
            j+=1
            if cur<=P:
                res=max(res,j-i)
        else:
            cur-=A[i]
            i+=1
            if cur<=P:
                res=max(res,j-i)
    print(res)

main()
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/018ms2968 KiB
2Accepted0/0111ms13528 KiB
3Accepted3/317ms2964 KiB
4Accepted3/318ms2916 KiB
5Accepted3/317ms2936 KiB
6Accepted3/317ms3052 KiB
7Accepted3/317ms2936 KiB
8Accepted4/417ms2828 KiB
9Accepted4/417ms2916 KiB
10Accepted5/518ms3044 KiB
11Accepted5/527ms3716 KiB
12Accepted5/528ms4204 KiB
13Accepted7/781ms5396 KiB
14Accepted7/7100ms10060 KiB
15Accepted7/7108ms13288 KiB
16Accepted8/8101ms10936 KiB
17Accepted8/8108ms13412 KiB