113412024-08-20 22:43:02probaLeghosszabb nyaralás (75 pont)python3Time limit exceeded 28/75298ms13508 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 sum(t)+i <= penz:
        t += [i]
        if len(t) > h:
            h = len(t)
    else:
        t +=[i]
        while sum(t) > penz:
            t=t[1:]

print(h)
        
    
            
        
    
    
    
    
SubtaskSumTestVerdictTimeMemory
base28/75
1Accepted0/017ms3044 KiB
2Time limit exceeded0/0296ms13508 KiB
3Accepted3/317ms2980 KiB
4Accepted3/317ms2920 KiB
5Accepted3/317ms3044 KiB
6Accepted3/317ms3064 KiB
7Accepted3/317ms3048 KiB
8Accepted4/417ms2940 KiB
9Accepted4/419ms3044 KiB
10Accepted5/525ms3068 KiB
11Time limit exceeded0/5298ms3660 KiB
12Time limit exceeded0/5296ms4068 KiB
13Time limit exceeded0/7293ms5496 KiB
14Time limit exceeded0/7298ms10040 KiB
15Time limit exceeded0/7296ms13292 KiB
16Time limit exceeded0/8298ms10868 KiB
17Time limit exceeded0/8298ms13428 KiB