Rezultati

Up. imeNalogaJezikRezultatČas oddaje
TDT-2018 Priprava naloge Python 3 100/100OK 19. apr '18 @ 16:50

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 8,984 MiB 0,196 s OK
#2 11/11 8,988 MiB 0,216 s OK
#3 11/11 8,941 MiB 0,191 s OK
#4 11/11 9,152 MiB 0,160 s OK
#5 11/11 9,625 MiB 0,232 s OK
#6 11/11 11,410 MiB 0,206 s OK
#7 11/11 9,129 MiB 0,000 s OK
#8 11/11 15,738 MiB 0,000 s OK
#9 12/12 9,039 MiB 0,000 s OK

Ocenjevani program (naloga.py):
import sys
from collections import deque

inp = sys.stdin.readline
k, n = map(int, inp().split())

ok = False

vsotaur = 0
vsotac = 0

tr = 0
vsota = 0
deck = deque([])

minimum = False


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

    tr += t
    vsota += c
    deck.append((t, c))
    vsotaur += t
    vsotac += c

    if tr >= k:
        if minimum is False or vsota < minimum:
            minimum = vsota
            ok = True

        zadnji = deck.popleft()
        tr -= zadnji[0]
        vsota -= zadnji[1]
        while tr >= k:
            if minimum is False or vsota < minimum:
                minimum = vsota
                ok = True

            zadnji = deck.popleft()
            tr -= zadnji[0]
            vsota -= zadnji[1]


if ok is False:
    print("Tekma bo polom")
else:
    print(vsotac - minimum)