113002024-08-04 22:53:10probaLeghosszabb nyaralás (75 pont)python3Wrong answer 0/7587ms13796 KiB
#nyaralás
#sor1 = '8 10'; sor2 = '3 6 4 2 3 7 2 9'
sor1 = input(); sor2 = input()

l1 = list(map(int, sor1.split(' ')))
N, m = l1[0], l1[1]
nap = list(map(int, sor2.split(' ')))

hossz = 1
osszeg, ah, fh = 0, 0, 1
i = 1

while fh < N:
    #print(fh, ah)
    while osszeg < m:
        osszeg += nap[fh]
        fh += 1
        if fh - ah > hossz:
            hossz = fh - ah
    
    while osszeg > m:
        osszeg -= nap[ah]
        ah += 1
    fh += 1
        
print(hossz)        
        
SubtaskSumTestVerdictTimeMemory
base0/75
1Accepted0/018ms2916 KiB
2Wrong answer0/079ms13796 KiB
3Wrong answer0/317ms2980 KiB
4Runtime error0/317ms2916 KiB
5Wrong answer0/318ms3064 KiB
6Wrong answer0/317ms2916 KiB
7Wrong answer0/317ms3100 KiB
8Wrong answer0/417ms2936 KiB
9Wrong answer0/418ms2988 KiB
10Wrong answer0/518ms3100 KiB
11Wrong answer0/524ms3756 KiB
12Wrong answer0/524ms4088 KiB
13Runtime error0/787ms5532 KiB
14Wrong answer0/779ms10396 KiB
15Wrong answer0/782ms13544 KiB
16Wrong answer0/883ms11336 KiB
17Wrong answer0/878ms13796 KiB