113022024-08-04 22:59:25probaLeghosszabb nyaralás (75 pont)python3Wrong answer 4/7593ms13944 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 True:
    #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
    if fh+hossz > N:
        break
        
print(hossz)        
        
SubtaskSumTestVerdictTimeMemory
base4/75
1Accepted0/017ms2960 KiB
2Wrong answer0/076ms13872 KiB
3Wrong answer0/317ms2916 KiB
4Runtime error0/318ms3044 KiB
5Wrong answer0/318ms3028 KiB
6Wrong answer0/317ms2924 KiB
7Wrong answer0/317ms3044 KiB
8Accepted4/417ms2932 KiB
9Wrong answer0/418ms2960 KiB
10Wrong answer0/518ms2916 KiB
11Wrong answer0/523ms3832 KiB
12Wrong answer0/524ms3940 KiB
13Runtime error0/793ms5524 KiB
14Wrong answer0/771ms10292 KiB
15Wrong answer0/776ms13596 KiB
16Wrong answer0/871ms11188 KiB
17Wrong answer0/881ms13944 KiB