113432024-08-20 22:46:16probaLeghosszabb nyaralás (75 pont)python3Wrong answer 21/75298ms13460 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:
            osszeg -= t[0]
            t = t[1:]

print(h)
        
    
            
        
    
    
    
    
SubtaskSumTestVerdictTimeMemory
base21/75
1Wrong answer0/017ms2960 KiB
2Time limit exceeded0/0298ms13412 KiB
3Wrong answer0/317ms2960 KiB
4Accepted3/317ms2960 KiB
5Accepted3/317ms3048 KiB
6Accepted3/317ms3044 KiB
7Accepted3/317ms3044 KiB
8Wrong answer0/417ms2968 KiB
9Accepted4/418ms3072 KiB
10Accepted5/521ms3044 KiB
11Time limit exceeded0/5296ms3896 KiB
12Time limit exceeded0/5210ms4068 KiB
13Time limit exceeded0/7296ms5644 KiB
14Time limit exceeded0/7298ms10016 KiB
15Time limit exceeded0/7298ms13288 KiB
16Time limit exceeded0/8296ms10848 KiB
17Time limit exceeded0/8294ms13460 KiB