Problem:


Score : 300 points

Problem Statement

Snuke is making sugar water in a beaker.
Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.

Operation 1: Pour 100A grams of water into the beaker.

Operation 2: Pour 100B grams of water into the beaker.

Operation 3: Put C grams of sugar into the beaker.

Operation 4: Put D grams of sugar into the beaker.

In our experimental environment, E grams of sugar can dissolve into 100 grams of water.

Snuke will make sugar water with the highest possible density.

The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.
Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.
If there is more than one candidate, any of them will be accepted.

We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent.
Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.

Constraints

1 \leq A < B \leq 30

1 \leq C < D \leq 30

1 \leq E \leq 100

100A \leq F \leq 3 000

A, B, C, D, E and F are all integers.

Inputs

Input is given from Standard Input in the following format:

A B C D E F

Outputs

Print two integers separated by a space.
The first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.

Sample Input 1

1 2 10 20 15 200

Sample Output 1

110 10

In this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.

We can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.
It is not possible to make sugar water with higher density.
For example, the following sequences of operations are infeasible:

If we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.

If we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.

Sample Input 2

1 2 1 2 100 1000

Sample Output 2

200 100

There are other acceptable outputs, such as:

400 200

However, the output below is not acceptable:

300 150

This is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.

Sample Input 3

17 19 22 26 55 2802

Sample Output 3

2634 934



Sample input:
1 2 10 20 15 200


Sample output:
110 10

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_sugar = F / (100 + E) * E
max_water = F - max_sugar

sugars = set()
waters = set()
for i in range(F):
    for j in range(F):
        w = 100 * A * i + 100 * B * j
        if (i + j) != 0 and w <= max_water:
            waters.add(w)
        if w > max_water:
            break

for i in range(F):
    for j in range(F):
        s = C * i + D * j
        if (i + j) != 0 and s <= max_sugar:
            sugars.add(s)
        if s > max_sugar:
            break

sugar_waters = []
for water in waters:
    for sugar in sugars:
        sugar_water = water + sugar
        noudo = sugar / water
        if sugar_water <= F and noudo <= (E / 100):
            sugar_waters.append([sugar_water, sugar])

ans = max(sugar_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_sugar = F / (100 + E) * E
max_water = F - max_sugar

sugars = set()
waters = set()
a = int(F / 100)
for i in range(a):
    for j in range(a):
        w = 100 * A * i + 100 * B * j
        if (i + j) != 0 and w <= max_water:
            waters.add(w)
        if w > max_water:
            break

for i in range(F):
    for j in range(F):
        s = C * i + D * j
        if (i + j) != 0 and s <= max_sugar:
            sugars.add(s)
        if s > max_sugar:
            break

sugar_waters = []
for water in waters:
    for sugar in sugars:
        sugar_water = water + sugar
        noudo = sugar / water
        if sugar_water <= F and noudo <= (E / 100):
            sugar_waters.append([sugar_water, sugar])

ans = max(sugar_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_suger = F / (100 + E) * E
max_water = F - max_suger

sugers = set()
waters = set()
a = int(F / 100)
for i in range(a):
    for j in range(a):
        w = 100 * A * i + 100 * B * j
        if i + j != 0 and w <= max_water:
            waters.add(w)
        if w > max_water:
            break

for i in range(F):
    for j in range(F):
        s = C * i + D * j
        if i + j != 0 and s <= max_suger:
            sugers.add(s)
        if s > max_suger:
            break
            
suger_waters = []
for water in waters:
    for suger in sugers:
        suger_water = water + suger
        noudo = suger / water
        if suger_water <= F and noudo <= E / 100:
            suger_waters.append([suger_water, suger])

ans = max(suger_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_suger = F / (100 + E) * E
max_water = F - max_suger

sugers = []
waters = []
a = int(F / 100)
for i in range(a):
    for j in range(a):
        w = 100 * A * i + 100 * B * j
        if i + j != 0 and w <= max_water:
            waters.append(w)
        if w > max_water:
            break

for i in range(F):
    for j in range(F):
        s = C * i + D * j
        if i + j != 0 and s <= max_suger:
            sugers.append(s)
        if s > max_suger:
            break
print(sugers,waters)
suger_waters = []
for water in waters:
    for suger in sugers:
        suger_water = water + suger
        noudo = suger / water
        if suger_water <= F and noudo <= E / 100:
            suger_waters.append([suger_water, suger])

ans = max(suger_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_suger = F / (100 + E) * E
max_water = F - max_suger

sugers = []
waters = []
a = int(F / 100)
for i in range(a):
    for j in range(a):
        w = 100 * A * i + 100 * B * j
        if i + j != 0 and w <= max_water:
            waters.append(w)

for i in range(F):
    for j in range(F):
        s = C * i + D * j
        if i + j != 0 and s <= max_suger:
            sugers.append(s)

suger_waters = []
for water in waters:
    for suger in sugers:
        suger_water = water + suger
        noudo = suger / water
        if suger_water <= F and noudo <= E / 100:
            suger_waters.append([suger_water, suger])

ans = max(suger_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

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

max_sugar = F / (100 + E) * E
max_water = F - max_sugar
# print('w_max', max_water, 's_max', max_sugar)

waters = []
sugers = []
for i in range(F):
    for j in range(F):
        a_water_g = 100 * A
        b_water_g = 100 * B

        w = a_water_g * i + b_water_g * j
        if w <= max_water and i + j != 0:
            w_combi = [i, j, w]
            waters.append(w_combi)
            # print('w', w_combi)
        s = C * i + D * j
        if s <= max_sugar and i + j != 0:
            s_combi = [i, j, s]
            sugers.append(s_combi)
            # print('s', s_combi)

suger_waters = []
for water in waters:
    for suger in sugers:
        w_sousa_num = water[0] + water[1]
        s_sousa_num = suger[0] + suger[1]
        if suger[2] / water[2] <= E / 100:
            # print(water, suger)
            # print(' sw, s\n', water[2] + suger[2], suger[2])
            suger_waters.append([water[2] + suger[2], suger[2]])

ans = max(suger_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

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

max_sugar = F / (100 + E) * E
max_water = F - max_sugar
# print('w_max', max_water, 's_max', max_sugar)
range_arg = 30
# range_arg = int(F / (100 * A + C))
waters = []
sugers = []
for i in range(range_arg):
    for j in range(range_arg):
        a_water_g = 100 * A
        b_water_g = 100 * B

        w = a_water_g * i + b_water_g * j
        if w <= max_water and i + j != 0:
            w_combi = [i, j, w]
            waters.append(w_combi)
            # print('w', w_combi)
        s = C * i + D * j
        if s <= max_sugar and i + j != 0:
            s_combi = [i, j, s]
            sugers.append(s_combi)
            # print('s', s_combi)

suger_waters = []
for water in waters:
    for suger in sugers:
        w_sousa_num = water[0] + water[1]
        s_sousa_num = suger[0] + suger[1]
        if suger[2] / water[2] <= E / 100:
            # print(water, suger)
            # print(' sw, s\n', water[2] + suger[2], suger[2])
            suger_waters.append([water[2] + suger[2], suger[2]])

ans = max(suger_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
W = set()
S = set()
wtr = 100*A
sgr = 0

i = 1
j = 0
while(wtr <= F):
  while(wtr <= F):
    W.add(wtr)
    wtr = i*A*100 + j*B*100
    j +=1
  i +=1
  j = 0
  wtr = i*A*100 + j*B*100
  
i = 0
j = 0
while(sgr <= F):
  while(sgr <= F):
    S.add(sgr)
    sgr = i*C + j*D
    j +=1
  i +=1
  j = 0
  sgr = i*C + j*D
answtr = 100*A
anssgr = 0
  
for wtr in sorted(list(W), reversed):
  for sgr in sorted(list(S), reversed):
    if (sgr*(answtr+anssgr) > anssgr*(wtr+sgr)) and (sgr*(100+E)<=E*(wtr+sgr) and (wtr+sgr<=F)):
      answtr = wtr
      anssgr = sgr
      if anssgr*(100+E)==E*(answtr+anssgr):
        print("{} {}".format(answtr+anssgr, anssgr))
        exit()
print("{} {}".format(answtr+anssgr, anssgr))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
W = set()
S = set()
wtr = 100*A
sgr = 0

i = 1
j = 0
while(wtr <= F):
  while(wtr <= F):
    W.add(wtr)
    wtr = i*A*100 + j*B*100
    j +=1
  i +=1
  j = 0
  wtr = i*A*100 + j*B*100
  
i = 0
j = 0
while(sgr <= F):
  while(sgr <= F):
    S.add(sgr)
    sgr = i*C + j*D
    j +=1
  i +=1
  j = 0
  sgr = i*C + j*D
answtr = 100*A
anssgr = 0
  
for wtr in W:
  for sgr in S:
    if (sgr*(answtr+anssgr) > anssgr*(wtr+sgr)) and (sgr*(100+E)<=E*(wtr+sgr) and (wtr+sgr<=F)):
      answtr = wtr
      anssgr = sgr
      if (anssgr*(100+E)==E*(answtr+anssgr):
          print("{} {}".format(answtr+anssgr, anssgr))
          exit()
print("{} {}".format(answtr+anssgr, anssgr))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
W = set()
S = set()
wtr = 100*A
sgr = 0

i = 1
j = 0
while(wtr <= F):
  while(wtr <= F):
    W.add(wtr)
    wtr = i*A*100 + j*B*100
    j +=1
  i +=1
  j = 0
  wtr = i*A*100 + j*B*100
  
i = 0
j = 0
while(sgr <= F):
  while(sgr <= F):
    S.add(sgr)
    sgr = i*C + j*D
    j +=1
  i +=1
  j = 0
  sgr = i*C + j*D
answtr = 100*A
anssgr = 0
  
for wtr in W:
  for sgr in S:
    if (sgr*(answtr+anssgr) > anssgr*(wtr+sgr)) and (sgr*(100+E)<=E*(wtr+sgr) and (wtr+sgr<=F)):
      answtr = wtr
      anssgr = sgr
      if (ansgr*(100+E)==E*(answtr+anssgr):
          print("{} {}".format(answtr+anssgr, anssgr))
          exit()
print("{} {}".format(answtr+anssgr, anssgr))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input())

waters = set()
for i in range(F + 1):
    for j in range(F + 1):
        water = 100 * A * i + 100 * B * j
        if water <= F:
            waters.add(water)
waters.remove(0)

sugars = set()
for i in range(F + 1):
    for j in range(F + 1):
        sugar = C * i + D * j
        if sugar <= F:
            sugars.add(sugar)

max_percentage = 0
max_water = 0
max_sugar = 0
limit_percentage = (100 * E) / (100 + E)

for water in waters:
    for sugar in sugars:
        percentage = (100 * sugar) / (water + sugar)
        if max_percentage < percentage <= limit_percentage and water + sugar <= F:
            max_percentage = percentage
            max_water = water
            max_sugar = sugar

print('{} {}'.format(max_water + max_sugar, max_sugar))

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
ans = []
for ai in range(31):
    bb = (f - (ai * a * 100)) // b
    for bi in range(bb):
        if ai == bi == 0:
        continue
        cc = (f - (ai * a * 100 + bi * b * 100)) // c
        for ci in range(cc):
            dd = (f - (ai * a * 100 + bi * b * 100 + ci * c)) // d
            for di in range(dd):
                if 100 * a * ai + 100 * b * bi + c * ci + d * di <= f:
                    if (c * ci + d * di)/(100 * a * ai + 100 * b * bi) <= e/100:
                        ans.append([(c * ci + d * di)/(100 * a * ai + 100 * b * bi + c * ci + d * di), 100 * a * ai + 100 * b * bi + c * ci + d * di, c * ci + d * di])
ans.sort(reverse=True)
print(ans[0][1], ans[0][2])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
water=[]
salt=[]
for i in range(30):
  for j in range(30):
    x=a*100*i+b*100*j
    if x<=f:
      water.append(x)
for i in range(1501):
  for j in range(1501):
    x=c*i+d*j
    if x<=f:
      salt.append(x)
water=list(set(water))
salt=list(set(salt))
stack=0
ans_sol=0
ans_sal=0
for i in water:
  for j in salt:
    if i+j<=f and j*100<=i*c:
      if j/(i+j)>stack:
        stack=j/(i+j)
        ans_sol=i+j
        ans_sal=j
print(ans_sol,ans_sal)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=[]
for i in range(f//100//a +1):
  for j in range(f//100//b +1):
    if i*a*100+j*b*100<=f:
      for p in range(f//c +1):
        for q in range(f//d +1):
          if p*c+q*d<=(i*a+j*b)*e and (p*c+q*d+i*a*100+j*b*100<=f):
            ans.append([p*c+q*d+i*a*100+j*b*100,p*c+q*d])
stack=0
index=0
for i in ans:
  if stack<i[0]/i[1]:
    stack=i[0]/i[1]
    index=i
if index==0:
  print(0,0)
else:
  print(ans[index])

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=list(map(int, input().split()))

from fractions import gcd

highest_concentration=0

for a in range(F//(100*A) +1):
  for b in range((F-100*A*a)//(100*B) +1):
    water = 100*A*a + 100*B*b
    if not water:
      continue
    max_sugar = min(E*(A*a+B*b), F-water)
    
    lcm = C*D//gcd(C,D)
    
    #(max_sugar//lcm)*lcm
    for c in range((max_sugar%lcm)//C + 1):
      d = (max_sugar%lcm -c*C)//D
      
      sugar = (max_sugar//lcm)*lcm + c*C + d*D
      if sugar/(water+sugar) > highest_concentration:
        highest_concentration = sugar/(water+sugar)
        #print(a,b,c,d, 100*a*A+100*b*B, sugar)
        #print(water,water+sugar, sugar)
        answer = (water+sugar, sugar)
        
print(*answer)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=list(map(int, input().split()))

from fractions import gcd

highest_concentration=0

for a in range(F//(100*A) +1):
  for b in range((F-100*A*a)//(100*B) +1):
    water = 100*A*a + 100*B*b
    if not water:
      continue
    max_sugar = min(E*(A*a+B*b), F-water)
    
    lcm = C*D//gcd(C,D)
    
    #(max_sugar//lcm)*lcm
    for c in range((max_sugar%lcm)//C + 1):
      d = (max_sugar%lcm -c*C)//D
      
      sugar = (max_sugar//lcm)*lcm + c*C + d*D
      if sugar/(water+sugar) > highest_concentration:
        highest_concentration = sugar/(water+sugar)
        #print(a,b,c,d, 100*a*A+100*b*B, sugar)
        #print(water,water+sugar, sugar)
        answer = (water+sugar, sugar)
print(*answer)A,B,C,D,E,F=list(map(int, input().split()))

from fractions import gcd

highest_concentration=0

for a in range(F//(100*A) +1):
  for b in range((F-100*A*a)//(100*B) +1):
    water = 100*A*a + 100*B*b
    if not water:
      continue
    max_sugar = min(E*(A*a+B*b), F-water)
    
    lcm = C*D//gcd(C,D)
    
    #(max_sugar//lcm)*lcm
    for c in range((max_sugar%lcm)//C + 1):
      d = (max_sugar%lcm -c*C)//D
      
      sugar = (max_sugar//lcm)*lcm + c*C + d*D
      if sugar/(water+sugar) > highest_concentration:
        highest_concentration = sugar/(water+sugar)
        #print(a,b,c,d, 100*a*A+100*b*B, sugar)
        #print(water,water+sugar, sugar)
        answer = (water+sugar, sugar)
print(*answer)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range1,(f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<dp[i]*100/(i-dp[i]):
      stack=dp[i]*100/(i-dp[i])
      index=i
print(index,dp[index])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range(f+1):
  for j in [a*100,b*100]:
    if dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<dp[i]*100/(i-dp[i]):
      stack=dp[i]*100/(i-dp[i])
      index=i
print(index,dp[index])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range(f+1):
  for j in [a*100,b*100]:
    if dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(f+1):
  if dp[i]!=0:
    if stack<dp[i]*100/(i-dp[i]):
      stack=dp[i]*100/(i-dp[i])
      index=i
print(index,dp[index])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range(f+1):
  for j in [a*100,b*100]:
    if dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=0
for i in range(f+1):
  if dp[i]!=0:
    if stack<dp[i]*100/(i-dp[i]):
      stack=dp[i]*100/(i-dp[i])
      index=i
print(index,dp[index])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range(f+1):
  for j in [a*100,b*100]:
    if dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=0
for i in range(f+1):
  if dp[i]!=0:
    if stack<dp[i]*100//(i-dp[i]):
      stack=dp[i]*100//(i-dp[i])
      index=i
print(index,dp[index])

Submission status: Runtime Error

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

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) > rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())

lis=[]
for i in range(int(f/(100*a))+1):
    for j in range(int(f/(100*b))+1):
        if 100*a*i+100*b*j <= f and 100*a*i+100*b*j>f/2:
            lis.append(100*a*i+100*b*j)
lis.sort()

suglis=[]
for i in range(int((f*e/(100+e))/c)+1):
    for j in range(int((f*e/(100+e))/d)+1):
        if i*c+j*d<=f*e/(100+e):
            suglis.append(i*c+j*d)
suglis.sort()

import numpy as np
res_wrt_water =[]
for i in lis:
    ind=1
    while suglis[-ind]/i>e/100 or suglis[-ind]+i>f:
        ind+=1
        if ind==n:
            break
        
      
    res_wrt_water.append([suglis[-ind]/i,i,suglis[-ind]])
ar = np.array(res_wrt_water,dtype='float32')


print(int(ar[np.argmax(ar[:,0])][1]+ar[np.argmax(ar[:,0])][2]),int(ar[np.argmax(ar[:,0])][2]))

Submission status: Runtime Error

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

ans = {}


def main():
    MAX_A = F // (100 * A)

    for i in range(MAX_A + 1):
        MAX_B = (F - i * 100 * A) // (100 * B)

        for j in range(MAX_B + 1):
            if i == 0 and j == 0:
                continue

            a = i * A + j * B

            SAT = a * E

            if F - a * 100 < SAT:
                continue

            MAX_C = SAT // C

            for k in range(MAX_C + 1):
                l = (SAT - k * C) // D

                b = k * C + l * D
                if (SAT == b):
                    print(a * 100 + b, b)
                    return

                LACK = SAT - b
                if not LACK in ans:
                    ans[LACK] = (a * 100 + b, b)

    print(" ".join([str(i) for i in ans[min(ans.keys())]]))
    return


main()

Submission status: Runtime Error

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


def main():
    sa = {100 * i * A + 100 * j * B
          for i in range(F) for j in range(F)
          if 100 * i * A + 100 * j * B <= F and i + j != 0}

    sb = {i * C + j * D for i in range(F) for j in range(F)
          if i * C + j * D <= F and i + j != 0}

    a = sorted(sa)
    b = sorted(sb)

    conc = 0.0

    for i in a:
        for j in b:
            if F < i + j:
                break
            if E * i / 100 < j:
                break

            if conc < j / (i + j) * 100:
                conc = j / (i + j) * 100
                water = i
                sugar = j

    print(water + sugar, sugar)
    return


main()

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
waters = set()
sugars = set()
for i in range(F//(A*100)+1):
    for j in range(F//(B*100)+1):
        if i!=0 or j!=0:
            if A*i +B*j <= F:
                waters.add(100*A*i+100*B*j)
for i in range(F//(C)+1):
    for j in range(F//(D)+1):
        if C*i +D*j <= F:
            sugars.add(C*i+D*j)

max_ratio = 0
for water in waters:
    for sugar in sugars:
        ratio =  sugar/(water+sugar)
        if water+sugar<=F and sugar<=E*(water//100):
            if ratio > max_ratio:
                ans = (water+sugar, sugar)
                max_ratio = ratio
print(*ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/23
Solved on 2019/3/
@author: shinjisu
"""


# ABC 074 C - Sugar Water

def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替
class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def conc(maxconc, water, sugar):
    global E, F
    if sugar == 0:
        return 0
    conc = sugar / (sugar+water*100) * 100
    if sugar/water > E:  # not all melted
        return -11
    elif water*100+sugar > F:  # overflow
        return -5
    elif conc > maxconc:
        return conc
    else:
        return -1


def prob():
    global E, F
    db = Debug()
    db.off()
    A, B, C, D, E, F = getIntList()
    db.dmp((A, B, C, D, E, F), 'A, B, C, D, E, F')
    a = F // (100 * A)
    b = F // (100 * B)
    c = F // C
    d = F // D
    db.dmp((a, b, c, d), 'a, b, c, d')
    maxConc, maxWater, maxSugar = -1.0, 0, 0
    for i in range(0, a+1):
        for j in range(0, b+1):
            water = A*i + B*j
            if water*100 >= F:  # overflow
                break
            for n in range(0, c+1):
                for m in range(0, d+1):
                    sugar = C*n + D*m
                    cn = conc(maxConc, water, sugar)
                    if cn > 0:
                        maxConc, maxWater, maxSugar = cn, water, sugar
                    elif cn < -10:
                        break

    db.dmp((maxConc, maxWater, maxSugar),'max conc, water, sugar')
    return maxWater*100+maxSugar, maxSugar


ans = prob()
for elm in ans:
    print(elm, end=' ')

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = map(int,input().split())
concent = 0
ans = []
for one in range(F//(100*A)+1):
    for two in range((F-100*A*one)//(100*B)+1):
        for three in range((F-100*A*one-100*B*two)//C+1):
            for four in range((F-100*A*one-100*B*two-C*three)//D+1):
                water = 100*A*one+100*B*two
                sugar = C*three+D*four
                all = water + sugar
                if all == 0:
                    continue
                if E*water//100 < sugar or all > F:
                    continue
                if concent < 100*sugar/all:
                    concent = 100*sugar/all
                    ans = [all,sugar]
print(str(ans[0])+' '+str(ans[1]))

Submission status: Runtime Error

Solution code:
import math
A,B,C,D,E,F = map(int, input().split())
water = A
suger = 0
for a in range(31):
    for b in range(31):
        subwater = A * a + B * b
        if subwater == 0:
                continue
        for c in range(151):
            subsuger = C * c
            if subsuger <= subwater * E:
                subsuger += D * min(F - subwater * 100 - subsuger, ((subwater * E - subsuger) // D))
                if subsuger <= subwater * E and subwater * 100 + subsuger <= F and subsuger / (subwater * 100 + subsuger) > suger / (water * 100 + suger):
                    water = subwater
                    suger = subsuger
print("{} {}".format(water * 100 + suger, suger))
print(0//D)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
g = max(a, b)
h = min(a, b)
salt = []
water = []
concentration = 0

for i in range(int(e*f/(c*100)) + 1):
    j = 0
    while e*f/100 >= c*i +d*j:
        salt.append(c*i+d*j)
        j += 1
salt.sort()

for i in range(int(f/(100*g))+1):
    j = 0
    while f >= 100*(g*i+h*j):
        water.append(100*(g*i+h*j))
        j += 1
water.sort()
water = water[1:]

for i in range(len(water)):
    addsalt = min(water[i] * e // 100, f - water[i])
    while addsalt not in salt and addsalt > 0:
        addsalt -=1
    if concentration < addsalt / (water[i] + addsalt):
        concentration = addsalt / (water[i] + addsalt)
        salt1 = addsalt
        water1 = water[i]

print(salt1+water1, salt1)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
g = max(a, b)
h = min(a, b)
salt = []
water = []
concentration = 0

for i in range(int(e*f/(c*100)) + 1):
    j = 0
    while e*f/100 >= c*i +d*j:
        salt.append(c*i+d*j)
        j += 1
salt.sort()

for i in range(int(f/(100*g))+1):
    j = 0
    while f >= 100*(g*i+h*j):
        water.append(100*(g*i+h*j))
        j += 1
water.sort()
water = water[1:]

for i in range(len(water)):
    addsalt = min(water[i] * e // 100, f - water[i])
    while addsalt not in salt:
        addsalt -=1
    if concentration < addsalt / (water[i] + addsalt):
        concentration = addsalt / (water[i] + addsalt)
        salt1 = addsalt
        water1 = water[i]

print(salt1+water1, salt1)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
water = [100*i+100*j for i in range(1,(f//(a*100))+1) for j in range(1,(f//(b*100))+1)]
suger = [c*i+d*j for i in range(0,(f//c)+1) for j in range(0,(f//d)+1)]
print((f//(a*100))+1)
print((f//(b*100))+1)
water = set(water)
suger = set(suger)
print(sorted(water))
print(sorted(suger))
ans=set()
for wa in water:
    for su in suger:
        if 0 < wa + su <= f and  su <= (wa // 100) * e :
            ans.add((su/(wa+su),wa,su))

ans = sorted(ans)
print(ans[-1][1]+ans[-1][2],ans[-1][2])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
water = [100*i+100*j for i in range(0,int(3000/(a*100))+1) for j in range(0,int(
suger = [c*i+d*j for i in range(0,int(3000/c)+1) for j in range(0,int(3000/d)+1)
water = set(water)
suger = set(suger)
ans=set()
for wa in water:
    for su in suger:
        if 0 < wa + su <= f and  su <= (wa // 100) * e :
            ans.add((su/(wa+su),wa,su))
ans = sorted(ans)
print(ans[-1][1]+ans[-1][2],ans[-1][2])

Submission status: Runtime Error

Solution code:
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])

Submission status: Runtime Error

Solution code:
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)