113472024-08-20 23:05:24probaLeghosszabb nyaralás (75 pont)python3Time limit exceeded 45/75298ms13416 KiB
'''napok = 8; penz = 10
nap = list(map(int, '3 6 4 2 3 7 2 9'.split(' ')))

with open('be2.txt','r') as f:
    sor = list(map(int, f.readline().strip().split(' ')));
    nap = list(map(int, f.readline().strip().split(' ')))'''
sor = list(map(int, input().split(' '))); nap = list(map(int, input().split(' ')))
napok = sor[0]; penz = sor[1]

h = 0; osszeg = 0; t = []

for i in nap:
    
    #print(osszeg, t)
    
    osszeg += i; t += [i]
    
    if osszeg <= penz:
        x = len(t)
        if x > h:
            h = x
    else:
        while osszeg > penz:
            osszeg -= t[0]
            t.pop(0)
            


print(h)
        
    
            
        
    
    
    
    
SubtaskSumTestVerdictTimeMemory
base45/75
1Accepted0/018ms2952 KiB
2Time limit exceeded0/0298ms13416 KiB
3Accepted3/317ms2916 KiB
4Accepted3/317ms3052 KiB
5Accepted3/317ms3044 KiB
6Accepted3/317ms3044 KiB
7Accepted3/317ms3044 KiB
8Accepted4/417ms3008 KiB
9Accepted4/417ms3192 KiB
10Accepted5/517ms3180 KiB
11Accepted5/532ms3544 KiB
12Accepted5/528ms3956 KiB
13Accepted7/793ms5540 KiB
14Time limit exceeded0/7298ms10016 KiB
15Time limit exceeded0/7296ms13308 KiB
16Time limit exceeded0/8296ms11000 KiB
17Time limit exceeded0/8298ms13412 KiB