Problem p03599 (python)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
ans = []
water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
sugar = list(set(sugar))
sugar.remove(0)

            
for miz in water:
    for sato in sugar:
        if miz + sato <= F and sato / (miz + sato) <= E / (100 + E):
            ans.append([miz, sato, sato / (miz + sato)])
            
if ans:
    ans.sort(key=lambda x:x[2], reverse = True)
    print(ans[0][0]+ans[0][1], ans[0][1])
else:
    print(water[0], 0)

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

water = []
for a in range(31):
    for b in range(31):
        if a * A + b * B <= F:
            water.append(a * A + b * B)
water = list(set(water))
water.remove(0)

sugar = []

for c in range(3001):
    for d in range(3001):
        if c * C + d * D <= F:
            sugar.append(c * C + d * D)
sugar = list(set(sugar))
sugar.remove(0)

memo = []
for w in water:
    for s in sugar:
        if w + s <= F and s/w <= E/100:
            memo.append([s/(s+a),w+s, s])
memo.sort(reverse=True)
print(memo[0][1], memo[0][2])

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
ans = []
water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
sugar = list(set(sugar))
sugar.remove(0)

            
for miz in water:
    for sato in sugar:
        if miz + sato <= F and (100 * sato) // (miz + sato) <= (100 * E) // (100 + E):
            ans.append([miz, sato, (miz * sato) // (miz + sato)])
            
ans.sort(key=lambda x:x[2], reverse = True)
print(ans[0][0]+ans[0][1], ans[0][1])

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
ans = []
water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
sugar = list(set(sugar))
sugar.remove(0)

            
for miz in water:
    for sato in sugar:
        if miz + sato <= F and (100 * sato) / (miz + sato) <= (100 * E) / (100 + E):
            ans.append([miz, sato, (miz * sato) / (miz + sato)])
            
ans.sort(key=lambda x:x[2], reverse = True)
print(ans[0][0]+ans[0][1], ans[0][1])

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
ans = []
water = []
for i in range(31):
    for j in range(31):
        tmp = 100*i*A + 100*j*B
        if tmp <= F:
            water.append(tmp)
water = list(set(water))
water.remove(0)

sugar = []
for i in range(101):
    for j in range(101):
        tmp = i*C + j*D
        if tmp <= F:
            sugar.append(tmp)
sugar = list(set(sugar))
sugar.remove(0)

            
for miz in water:
    for sato in sugar:
        if miz + sato <= F and (miz * sato) / (miz + sato) <= (100 * E) / (100 + E):
            ans.append([miz, sato, (miz * sato) / (miz + sato)])
            
ans.sort(key=lambda x:x[2], reverse = True)
print(ans[0][0]+ans[0][1], ans[0][1])