Rezultati

Up. imeNalogaJezikRezultatČas oddaje
jelke-2018 Priprava naloge Python 3 0/100Prekoračen čas (TLE) 19. apr '18 @ 18:38

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 21,828 MiB 0,885 s OK
#2 11/11 21,832 MiB 1,057 s OK
#3 11/11 21,625 MiB 0,910 s OK
#4 11/11 21,742 MiB 1,073 s OK
#5 0/11 21,629 MiB 4,484 s Prekoračen čas
#6 0/11 21,762 MiB 4,489 s Prekoračen čas
#7 11/11 8,656 MiB 0,000 s OK
#8 0/11 15,484 MiB 4,560 s Prekoračen čas
#9 12/12 8,484 MiB 0,000 s OK

Ocenjevani program (priprava.py):
k, n = map(int, input().split())

dogodki = []

for i in range(n):
    t, c = map(int, input().split())
    dogodki.append((t, c))

s = 0
for i in range(n):
    s += dogodki[i][0]
if s < k:
    print('Tekma bo polom')
    exit()

ss = 0
for i in range(n):
    ss += dogodki[i][1]
m = ss
mm = ss

novs = 0

for i in range(n):
    novs = 0
    mc = 0
    j = i
    while True:
        if j >= n:
            break
       # print(j)
       # print(novs)
        if novs + dogodki[j][0] < k:
            novs += dogodki[j][0]
            j += 1
        else:
            novs += dogodki[j][0]
            break
    if novs >= k:
        #print('zacne')
        for l in range(i, j+1):
            mc += dogodki[l][1]
        if mc < m:
            m = mc
       # print(mc)
print(mm - m)