Problem p03599 (python)

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

a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans_total = 100*A
ans_sugar = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)

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

a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
total = 100*A
ans_sugar = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())
a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())
a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
            max_dens = dens
            ans_total = total
            ans_sugar = j
            
print(ans_total, ans_sugar)