Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 24,602 MiB 0,509 s OK
#2 11/11 24,742 MiB 0,499 s OK
#3 11/11 24,594 MiB 0,478 s OK
#4 11/11 24,742 MiB 0,610 s OK
#5 11/11 24,594 MiB 0,544 s OK
#6 11/11 24,742 MiB 0,539 s OK
#7 11/11 8,492 MiB 0,000 s OK
#8 11/11 18,555 MiB 0,139 s OK
#9 12/12 8,590 MiB 0,000 s OK

Ocenjevani program (naloga.py):
import sys

#sys.stdin = open("mesta.in")

inp = sys.stdin.readline

k,n = map(int, inp().split())
data = []
su_t = 0
su_c = 0
for j in range(n):
    t, c = map(int, inp().split())
    su_t += t
    su_c += c
    data.append([t,c])

#print(data)

# Process
last = 0
cur_cena = 0
cur_cajt = 0
global_min_cena = float("inf")
bur = 0
for j in range(0, len(data)):
    t, c = data[j]
    cur_cena += c
    cur_cajt += t
    bur = j
    if cur_cajt >= k:
        break


data.append([0,0])
if cur_cajt < k:
    print("Tekma bo polom")
    sys.exit(0)

global_min_cena = cur_cena


for top in range(bur+1, len(data)):
    t, c = data[top]
    cur_cena += c
    cur_cajt += t
    while 1:
        t, c = data[last]
        if cur_cajt - t >= k:
            last += 1
            cur_cena -= c
            cur_cajt -= t
        else:
            break
    global_min_cena = min(global_min_cena, cur_cena)


print(su_c - global_min_cena)