Rezultati

Up. imeNalogaJezikRezultatČas oddaje
zerodays-2018 Arbitraža Python 3 100/100OK 13. okt '18 @ 13:11

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 8,668 MiB 0,000 s OK
#2 11/11 34,277 MiB 0,720 s OK
#3 11/11 15,445 MiB 0,000 s OK
#4 11/11 19,340 MiB 0,000 s OK
#5 11/11 19,273 MiB 0,000 s OK
#6 11/11 22,711 MiB 0,296 s OK
#7 11/11 22,523 MiB 0,356 s OK
#8 11/11 8,742 MiB 0,000 s OK
#9 12/12 8,734 MiB 0,000 s OK

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

p = list(map(int, input().split()))
s = list(map(int, input().split()))

produkti = []

p.sort(reverse=True)
s.sort(reverse=True)

for i in range(min(n, m)):
    produkti.append(p[i] * s[i])

vsote_p = [0]
for i in range(len(p)):
    vsote_p.append(vsote_p[-1] + p[i])

vsote_s = [0]
for i in range(len(s)):
    vsote_s.append(vsote_s[-1] + s[i])

vsote_prod = [0]
for i in range(len(produkti)):
    vsote_prod.append(vsote_prod[-1] + produkti[i])

M = 0

if k >= len(p) + len(s):
    a = n
    b = m
    
    m = min(a, b)
    v = vsote_prod[m]

    if a >= b:    
        v += vsote_p[a] - vsote_p[m]
        M_1 = a * v
    else:
        v += vsote_s[b] - vsote_s[m]
        M_1 = b * v

    M = max(M, M_1)

else:
    for i in range(k + 1):
        a = i
        b = k - i

        if a > len(p) or b > len(s):
            continue

        m = min(a, b)
        v = vsote_prod[m]

        if a >= b:    
            v += vsote_p[a] - vsote_p[m]
            M_1 = a * v
        else:
            v += vsote_s[b] - vsote_s[m]
            M_1 = b * v
        
        M = max(M, M_1)




print(M)