Problem p03599 (python)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

density_d = {}
density = []

for i in water:
    suger_limit = E*(i//100)

    suger = []

    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and n + i <= F:
                suger.append(n)
    suger = max(suger)
    if i+suger == 0:
        continue
    else:
        density.append(100*suger/(i+suger))
        density_d[100*suger/(i+suger)] = [i + suger, suger]
density = list(set(density))
a, b = map(int, density_d[max(density)])
print(a,b)

Buggy submission (verdict: Runtime Error):

A, B, C, D, E, F = map(int, input().split())

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {"0":[0,0]}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]


a,b = map(int,result[str(max(noud))])

print(a,b)

Buggy submission (verdict: Runtime Error):

A, B, C, D, E, F = map(int, input().split())

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {"0",[0,0]}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]


a,b = map(int,result[str(max(noud))])

print(a,b)

Buggy submission (verdict: Runtime Error):

A, B, C, D, E, F = map(int, input().split())

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]

a = 0
b = 0
a,b = map(int,result[str(max(noud))])

print(a,b)

Buggy submission (verdict: Runtime Error):

A, B, C, D, E, F = map(int, input().split())

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]


a,b = map(int,result[str(max(noud))])

print(a,b)

Buggy submission (verdict: Runtime Error):

A, B, C, D, E, F = map(int, input().split())

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]


print(result[str(max(noud))])