Rezultati

Up. imeNalogaJezikRezultatČas oddaje
cimetovipolzki-2018 Priprava naloge Python 3 100/100OK 19. apr '18 @ 17:21

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 32,352 MiB 0,944 s OK
#2 11/11 32,191 MiB 0,888 s OK
#3 11/11 32,188 MiB 0,964 s OK
#4 11/11 32,266 MiB 0,924 s OK
#5 11/11 32,352 MiB 0,959 s OK
#6 11/11 32,352 MiB 0,908 s OK
#7 11/11 8,652 MiB 0,000 s OK
#8 11/11 26,016 MiB 0,609 s OK
#9 12/12 8,566 MiB 0,000 s OK

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

l = [list(map(int, input().strip().split())) for _ in range(n)]

min = float("inf")

c = 0
sum_u = 0
sum_d = 0

skup = 0
skup_u = 0
for i in range(n):
    skup += l[i][1]
    skup_u += l[i][0]

    sum_u += l[i][0]
    sum_d += l[i][1]

    while (sum_u - l[c][0]) >= k:
        sum_u -= l[c][0]
        sum_d -= l[c][1]
        c += 1
    if sum_u >= k and sum_d < min:
        min = sum_d

if (skup_u < k):
    print("Tekma bo polom")
else:
    print(skup-min)