113402024-08-20 21:41:04probaLeghosszabb nyaralás (75 pont)python3Time limit exceeded 28/75298ms13556 KiB
'''napok = 8; penz = 10
nap = list(map(int, '3 6 4 2 3 7 2 9'.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.pop(0)

print(h)
        
    
            
        
    
    
    
    
SubtaskSumTestVerdictTimeMemory
base28/75
1Accepted0/018ms3008 KiB
2Time limit exceeded0/0294ms13448 KiB
3Accepted3/317ms3056 KiB
4Accepted3/318ms2996 KiB
5Accepted3/317ms2960 KiB
6Accepted3/317ms2936 KiB
7Accepted3/317ms3064 KiB
8Accepted4/417ms3044 KiB
9Accepted4/419ms3044 KiB
10Accepted5/525ms3044 KiB
11Time limit exceeded0/5298ms3612 KiB
12Time limit exceeded0/5298ms4016 KiB
13Time limit exceeded0/7296ms5460 KiB
14Time limit exceeded0/7298ms10020 KiB
15Time limit exceeded0/7296ms13292 KiB
16Time limit exceeded0/8296ms10972 KiB
17Time limit exceeded0/8296ms13556 KiB