113032024-08-04 23:00:59probaLeghosszabb nyaralás (75 pont)python3Wrong answer 3/7587ms13944 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 = 0
osszeg, ah, fh = 0, 0, 0

while True:

    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
    if fh+hossz > N:
        break
        
print(hossz)        
        
SubtaskSumTestVerdictTimeMemory
base3/75
1Accepted0/017ms2980 KiB
2Wrong answer0/075ms13920 KiB
3Wrong answer0/317ms2916 KiB
4Runtime error0/318ms3044 KiB
5Wrong answer0/317ms3044 KiB
6Accepted3/317ms2916 KiB
7Wrong answer0/317ms2916 KiB
8Wrong answer0/417ms2960 KiB
9Wrong answer0/417ms3088 KiB
10Wrong answer0/517ms3044 KiB
11Wrong answer0/523ms3632 KiB
12Wrong answer0/523ms4000 KiB
13Runtime error0/787ms5716 KiB
14Wrong answer0/771ms10356 KiB
15Wrong answer0/775ms13564 KiB
16Wrong answer0/871ms11336 KiB
17Wrong answer0/879ms13944 KiB