113012024-08-04 22:56:13probaLeghosszabb nyaralás (75 pont)python3Wrong answer 7/7593ms13796 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

while fh < N-hossz:
    #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
base7/75
1Accepted0/017ms2964 KiB
2Wrong answer0/074ms13796 KiB
3Wrong answer0/318ms2960 KiB
4Runtime error0/317ms2952 KiB
5Wrong answer0/317ms2960 KiB
6Accepted3/317ms2976 KiB
7Wrong answer0/317ms3044 KiB
8Accepted4/417ms2960 KiB
9Wrong answer0/418ms2960 KiB
10Wrong answer0/517ms3044 KiB
11Wrong answer0/523ms3832 KiB
12Wrong answer0/524ms4068 KiB
13Runtime error0/793ms5568 KiB
14Wrong answer0/772ms10292 KiB
15Wrong answer0/778ms13724 KiB
16Wrong answer0/870ms11464 KiB
17Wrong answer0/879ms13796 KiB