Problem p03599 (python)

Fixed submission:
a,b,c,d,e,f = map(int, input().split())
water_list = []
for i in range(f+1):
    for j in range(f+1):
        water = a * 100 * i + b * 100 * j
        if water <= f:
            water_list.append(water)
        else:
            break
            
sugar_list = []
for i in range(f+1):
    for j in range(f+1):
        sugar = c * i + d * j
        if sugar <= f:
            sugar_list.append(sugar)
        else:
            break
            
ans = []
for i in list(set(water_list)):
    for j in list(set(sugar_list)):
        if i != 0:
            if float(j) / i  <= e / 100 and (i + j) <= f:
                ans.append((i+j, j))
                
ans_sorted = sorted(ans, key=lambda x: (x[1] / (x[0])))[-1]
print(ans_sorted[0],ans_sorted[1])

Buggy submission (verdict: Runtime Error):
a, b, c, d, e, f = map(int, input().split())
water = []
for i in range(31):
    for j in range(31):
        if a * i * 100 + b * j * 100 >= 3000:
            break
        water.append(a * i * 100 + b * j * 100)
        
water = sorted(list(set(water)))
sugar = []
for i in range(3001):
    for j in range(3001):
        if c * i + d * j >= 3000:
            break
        sugar.append(c * i + d * j)
        
sugar = sorted(list(set((sugar))))
sugar_ratio = 0
for i in water:
    for j in sugar:
        if i != 0 and j != 0:
            if (i + j) <= f:
                if j / i * 100 <= e:
                    if j / (i + j) > sugar_ratio:
                        sugar_ratio = j / (i + j)
                        ans_sugar_water = i + j
                        ans_sugar = j
            
            
print(ans_sugar_water, ans_sugar)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())

water_list = []
for i in range(f+1):
    for j in range(f+1):
        water = a * 100 * i + b * 100 * j
        if water <= f:
            water_list.append(water)
        else:
            break
sugar_list = []
for i in range(f+1):
    for j in range(f+1):
        sugar = c * i + d * j
        if sugar <= f:
            sugar_list.append(sugar)
        else:
            break
            
ans = []
for i in list(set(water_list)):
    for j in list(set(sugar_list)):
        if i != 0 and j != 0:
            if j / i * 100 <= e and (i + j) <= f:
                ans.append((i+j, j))
                
ans_sorted = sorted(ans, key=lambda x: (x[1] / (x[0])))[-1]
print(ans_sorted[0],ans_sorted[1])

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)

sugar_a = [0]
sugar_b = [0]
for i in range(100):
    for j in range(100):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check <= f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check <= f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))

from bisect import bisect_left,bisect_right
if sugar_sort_a == [0]:
    sugar_max_a = 0
else:
    sugar_max_a = sugar_sort_a[bisect_left(sugar_sort_a, max_a)]
a_check = sugar_max_a / (a* 100 + sugar_max_a)

if sugar_sort_b == [0]:
    sugar_max_b = 0
else:
    sugar_max_b = sugar_sort_b[bisect_left(sugar_sort_b, max_b)] 
b_check = sugar_max_b / (b*100 + sugar_max_b)

if a_check >= b_check:
    print(a*100+sugar_max_a, sugar_max_a)
if a_check < b_check:
    print(b*100+sugar_max_b, sugar_max_b)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)
 
sugar_a = []
sugar_b = []
for i in range(1501):
    for j in range(1501):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check <= f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check <= f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))
 
from bisect import bisect_left,bisect_right
sugar_max_a = sugar_sort_a[bisect_right(sugar_sort_a, max_a)-1]
a_check = sugar_max_a / (a* 100 + sugar_max_a)
 
sugar_max_b = sugar_sort_b[bisect_right(sugar_sort_b, max_b)-1] 
b_check = sugar_max_b / (b*100 + sugar_max_b)
 
if a_check >= b_check:
    print(a*100+sugar_max_a, sugar_max_a)
else:
    print(b*100+sugar_max_b, sugar_max_b)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)

sugar_a = []
sugar_b = []
for i in range(100):
    for j in range(100):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check <= f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check <= f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))

from bisect import bisect_left,bisect_right
sugar_max_a = sugar_sort_a[bisect_right(sugar_sort_a, max_a)-1]
a_check = sugar_max_a / (a* 100 + sugar_max_a)

sugar_max_b = sugar_sort_b[bisect_right(sugar_sort_b, max_b)-1] 
b_check = sugar_max_b / (b*100 + sugar_max_b)

if a_check >= b_check:
    print(a*100+sugar_max_a, sugar_max_a)
else:
    print(b*100+sugar_max_b, sugar_max_b)