113042024-08-04 23:27:40probaLeghosszabb nyaralás (75 pont)python3Wrong answer 11/75123ms13924 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, osszeg, ah, fh = 0, 0, 0, 0

while True:
    
    while osszeg <= m:
        
        osszeg += nap[fh]
        if osszeg <= m and fh - ah > hossz:
            hossz = fh - ah
        fh += 1
        

    while osszeg > m:
        osszeg -= nap[ah]
        if osszeg <= m and fh - ah > hossz:
            hossz = fh - ah
        ah += 1
    
    
    if fh+hossz > N:
        break
        
print(hossz)
SubtaskSumTestVerdictTimeMemory
base11/75
1Accepted0/017ms3044 KiB
2Wrong answer0/0122ms13840 KiB
3Accepted3/317ms2988 KiB
4Runtime error0/317ms2992 KiB
5Accepted3/317ms3044 KiB
6Wrong answer0/317ms3180 KiB
7Wrong answer0/317ms3192 KiB
8Wrong answer0/417ms2968 KiB
9Wrong answer0/417ms3104 KiB
10Wrong answer0/518ms3192 KiB
11Wrong answer0/523ms3824 KiB
12Accepted5/528ms4108 KiB
13Runtime error0/797ms5652 KiB
14Wrong answer0/785ms10220 KiB
15Wrong answer0/7116ms13800 KiB
16Wrong answer0/875ms11316 KiB
17Wrong answer0/8123ms13924 KiB