113442024-08-20 22:47:22probaLeghosszabb nyaralás (75 pont)python3Wrong answer 21/75300ms13452 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]
        osszeg += i
        if len(t) > h:
            h = len(t)
    else:
        t +=[i]
        while osszeg > penz:
            osszeg -= t[0]
            t = t[1:]

print(h)
        
    
            
        
    
    
    
    
SubtaskSumTestVerdictTimeMemory
base21/75
1Wrong answer0/018ms3044 KiB
2Time limit exceeded0/0296ms13452 KiB
3Wrong answer0/317ms3044 KiB
4Accepted3/317ms3044 KiB
5Accepted3/317ms2960 KiB
6Accepted3/317ms3052 KiB
7Accepted3/317ms3172 KiB
8Wrong answer0/418ms3184 KiB
9Accepted4/418ms3044 KiB
10Accepted5/521ms3192 KiB
11Time limit exceeded0/5294ms3812 KiB
12Time limit exceeded0/5210ms3988 KiB
13Time limit exceeded0/7296ms5644 KiB
14Time limit exceeded0/7293ms10212 KiB
15Time limit exceeded0/7298ms13292 KiB
16Time limit exceeded0/8296ms10992 KiB
17Time limit exceeded0/8300ms13420 KiB