113422024-08-20 22:44:49probaLeghosszabb nyaralás (75 pont)python3Time limit exceeded 3/75298ms13560 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:
    
    osszeg = 0 if len(t) == 0 else sum(t)
    
    #print(osszeg, t)
    
    if osszeg+i <= penz:
        t += [i]
        if len(t) > h:
            h = len(t)
    else:
        t +=[i]
        while osszeg > penz:
            t=t[1:]

print(h)
        
    
            
        
    
    
    
    
SubtaskSumTestVerdictTimeMemory
base3/75
1Time limit exceeded0/0293ms3052 KiB
2Time limit exceeded0/0296ms13488 KiB
3Time limit exceeded0/3298ms2916 KiB
4Accepted3/317ms2916 KiB
5Time limit exceeded0/3298ms2920 KiB
6Time limit exceeded0/3294ms2948 KiB
7Time limit exceeded0/3293ms3036 KiB
8Time limit exceeded0/4296ms3044 KiB
9Time limit exceeded0/4298ms3088 KiB
10Time limit exceeded0/5291ms3172 KiB
11Time limit exceeded0/5294ms3684 KiB
12Time limit exceeded0/5291ms4120 KiB
13Time limit exceeded0/7296ms5496 KiB
14Time limit exceeded0/7296ms10020 KiB
15Time limit exceeded0/7298ms13296 KiB
16Time limit exceeded0/8291ms10848 KiB
17Time limit exceeded0/8293ms13560 KiB