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())
threshold=E/(100+E)
water=[]
for i in range (int(F/(A*100)+1)):
    for j in range (int(F/(B*100)+1)):
        water.append(A*100*i+B*100*j)
sugar=[]
for k in range (int(F/(C)+1)):
    for l in range (int(F/(D)+1)):
        sugar.append(C*k+D*l)
sugar=list(set(sugar))
output=0
for i in range (len(water)):
    for j in range (len(sugar)):
        try:
            if threshold>=(int(sugar[j])/((int(water[i])+int(sugar[j])))) and (int(sugar[j])/((int(water[i])+int(sugar[j]))))>output and water[i]+sugar[j]<F:
                output=(int(sugar[j])/((int(water[i])+int(sugar[j]))))
                water_result=water[i]
                sugar_result=sugar[j]
        except ZeroDivisionError:
            continue
print(str(water_result+sugar_result)+' '+str(sugar_result))

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
water=[]
sugar=[]
ans,ans_2,con=0,0,0
for i in range(f//100+1):#f//100+1によりTLEを解消
    for j in range(f//100+1):
        x=100*a*i+100*j*b
        if x<=f:
            water.append(x)
for i in range(f):
    for j in range(f):
        y=c*i+d*j
        if y<=f:
            sugar.append(y)
sugar=list(set(sugar))
for i in water:
    for j in sugar:
        if i+j<=f:
            f j<=(i//100)*e:
                now=(100*j)/(i+j)
                if con<=now:
                    ans=i+j
                    ans_2=j
                    con=now
print(ans,ans_2)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int, raw_input().split())
noudo=int(float(E)/(100+E)*100)

a=[]
for i in range(noudo):
	for j in range(noudo):
		#print i,j
		if i*C+D*j<=noudo:
			a.append(i*C+D*j)

b=[]
cnt=F/100
for i in range(cnt):
	for j in range(cnt):
		if i*100+j*100<=F and i*100+j*100!=0:
			b.append(i*100+j*100)


noudo=float(E)/(100+E)*100
max_noudo=0
for i in a:
	for j in b:
		t_noudo=float(i)/(i+j)*100
		if t_noudo>max_noudo:
			max_noudo=t_noudo
			ans=i,j

print ans[0]+ans[1],ans[0]

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int, raw_input().split())
noudo=int(float(E)/(100+E)*100)

a=[]
for i in range(noudo):
	for j in range(noudo):
		#print i,j
		if i*C+D*j<=noudo:
			a.append(i*C+D*j)

b=[]
cnt=F/100
for i in range(cnt):
	for j in range(cnt):
		if i*100+j*100<=F and i*100+j*100!=0:
			b.append(i*100+j*100)


noudo=float(E)/(100+E)*100
max_noudo=0
for i in a:
	for j in b:
		t_noudo=float(i)/(i+j)*100
		if t_noudo>max_noudo:
			max_noudo=t_noudo
			ans=i,j

print ans[0],ans[1]

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f - i + 1, 100 * b):
        if i == 0 and j == 0:
            continue
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) / (i + j + k + l)
                if max_concentration < concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f - i + 1, 100 * b):
        if i == 0 and j == 0:
            continue
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) // (i + j + k + l)
                if max_concentration < concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=100
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        s=100*a*i+100*b*j
        if s==0:
            break
        for ii in range((f-100*a)//c+1):
            for jj in range((f-100*a)//d+1):
                t=c*ii+d*jj
                if t==0:
                    break
                u=(100*t)/s
                if s+t<=f and u==f:
                    print(str(s+t)+" "+str(t))
                    exit()
                if s+t<=f and u<e:
                    if ans>e-u:
                        ans=e-u
                        x,y=s,t
print(str(x+y)+" "+str(y))

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = map(int, input().split())
mw,ms = 0,0
i_times = int(F/(100*A)) + 1
j_times = int(F/(100*B)) + 1
k_times = int(F/(C)) + 1
l_times = int(F/(D)) + 1
ideal = E/(100+E)
bf = 0
for i in range(0,i_times):
    for j in range(0,j_times):
        for k in range(0,k_times):
            for l in range(0,l_times):
                w,s = 0,0
                w += i*A*100
                w += j*B*100
                s += k*C
                s += l*D
                if w + s > F:
                    break
                if s/(w+s) <= ideal and bf <= s/(w+s):
                    mw, ms = w,s
                    bf = s/(w+s)
print(mw+ms, ms)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = [int(item) for item in input().rstrip().split(" ")]

mizu_arr = []
for i in range(F // (A*100) + 1):
    for j in range((F - i * A * 100) // (B*100) + 1):
        mizu = i * A * 100 + j * B * 100
        if mizu > 0:
            mizu_arr.append(mizu)

mizu_arr = sorted(mizu_arr)

def func(sato):
    min_mizu = sato * 100.0 / E
    max_mizu = F - sato
    for mizu in mizu_arr:
        if max_mizu < mizu:
            return None
        if min_mizu <= mizu:
            return mizu
    return None

max_nodo = 0
max_sato = (F // (100 + E)) * E
for i in range(max_sato // C + 1):
    for j in range((max_sato - i * C) // D + 1):
        sato = i * C + j * D
        mizu = func(sato)
        if not mizu == None:
            if 100 * sato / (mizu + sato) > max_nodo:
                ans = [mizu + sato, sato]
                max_nodo = 100 * sato / (mizu + sato)
              
print("{} {}".format(ans[0], ans[1]))

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int,input().split())
maxden = 0
amax = f //(a*100)
for i in range(amax+1):
  waterA = i*100*a
  res = f-waterA
  bmax = res // (b*100)
  for j in range(bmax+1):
    waterB = j*100*b
    waterS =waterA+waterB
    res = f-waterS
    cmax = res // c
    for k in range(cmax+1):
      sugarC = k*c
      res = f-waterS-sugarC
      dmax = res // d
      for l in range(dmax+1):
        sugarD = l*d
        sugarS = sugarC+sugarD
        if(sugarS+waterS==0):break
        den = (sugarS)*100/(sugarS+waterS)
        #if(den>49 and den<50.1):print(res-sugarD,waterA,waterB,sugarC,sugarD,den)
        if(den>maxden and (den/100)<=(e/(100+e))):
          maxden = den
          sugar = sugarS
          water = waterS

print(str(water+sugar)+" "+str(sugar))

Submission status: Runtime Error

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

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D
                
                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if water + sugar <= F and sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max = 0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)

Submission status: Runtime Error

Solution code:

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

w = 0
s = 0
ratio = 0

for i in range(31):
    for j in range(31):
        water = a*i + b*j
        for k in range(1501):
            l = 0
            hoge = 1024
            while hoge:
                nl = l+hoge
                sugar = k*c+nl*d
                if 0 < water and water*100 + sugar <= f and sugar <= water*e:
                    l = nl
                hoge >>= 1
            sugar = k*c+l*d
            if ratio <= sugar / (water*100+sugar):
                w = water*100
                s = sugar
                ratio = sugar / (water*100+sugar)

print("%d %d"%(w+s,s))

Submission status: Runtime Error

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

w = 0
s = 0
ratio = 0

for i in range(31):
    for j in range(31):
        water = a*i + b*j
        for k in range(1501):
            l = 0
            hoge = 1024
            while hoge:
                nl = l+hoge
                sugar = k*c+nl*d
                if 0 < water and water*100 + sugar <= f and sugar <= water*e:
                    l = nl
                hoge <<= 2
            sugar = k*c+l*d
            if ratio <= sugar / (water*100+sugar):
                w = water*100
                s = sugar
                ratio = sugar / (water*100+sugar)

print("%d %d"%(w+s,s))

Submission status: Runtime Error

Solution code:
x = [int(i) for i in input().split()]
A = x[0]
B = x[1]
C = x[2]
D = x[3]
E = x[4]
F = x[5]

# とりうる水の量
WATER_MAX = int(F/100)
water = [False for i in range(WATER_MAX+1)]
tmp = 0
water_smaller = min(A,B)
water_bigger = max(A,B)
water[water_bigger] = True
while(1):
    tmp+=water_smaller
    if(tmp>WATER_MAX):
        break
    water[tmp]=True
    sum = tmp + water_bigger
    while(sum<=WATER_MAX):
        water[sum] = True
        sum+=water_bigger

#とりうる砂糖の量の最大
suger_max = [0 for i in range(WATER_MAX+1)]
suger_smaller = min(C,D)
suger_bigger = max(C,D)
water_amount = 0
for i in range(WATER_MAX+1):
    tmp_max = 0
    water_amount = 100*i
    if(water[i]==False):
        continue
    SUGER_MAX=i*E
    tmp = 0
    while(1):
        if(tmp>SUGER_MAX):
            break
        if(tmp+water_amount>F):
            break
        if(tmp_max<=tmp):
            tmp_max = tmp
        sum = tmp + suger_bigger
        while(sum<=SUGER_MAX and sum+water_amount<F):
            if(tmp_max<=sum):
                tmp_max = sum
            sum+=suger_bigger
        tmp+=suger_smaller
    suger_max[i] = tmp_max

#最大の濃度の検索
max_conc = 0.0
max_index = 0
for i in range(1,WATER_MAX+1):
    conc = suger_max[i] / (100.0*i+suger_max[i])
    if(conc>max_conc):
        max_conc = conc
        max_index = i

print(100*max_index+suger_max[max_index],suger_max[max_index])

Submission status: Runtime Error

Solution code:
#import numpy as np

def FindMaxCon(res, water, C, D, E):
  c = 0
  d = 0
  tmpCon = 0
  dp = list([False] * 3001)
  dp[0] = True
  for i in range(3001):
    if(i - C >= 0 and i - D >= 0):
      dp[i] = dp[i - C] or dp[i - D]
    elif(i - C >= 0):
      dp[i] = dp[i - C]
    elif(i - D >= 0):
      dp[i] = dp[i - D]
  tmpSugar = 0
  for i in range(min(res, E * water / 100) + 1):
    if(dp[i]):
      tmpSugar = i
  ans = tmpSugar
  return ans

A, B, C, D, E, F = (map(int, input().split()))
amax = F / (A * 100)
bmax = F / (B * 100)
amax = int(amax)
bmax = int(bmax)
water = 0
sugar = 0
waterAns= 0
sugarAns = 0
con = 0
conAns = 0
for a in range(1, amax + 1):
  for b in range(bmax + 1):
    water = 100 * (a * A + b * B)
    if(water > F):
      continue
    else:
      res = F - water
      tmp = FindMaxCon(res, water, C, D, E)
      sugar = tmp
      con = sugar / water
      if(con > conAns):
        conAns = con
        waterAns = water
        sugarAns = sugar
answer = str(waterAns + sugarAns) + " " + str(sugarAns)
print(answer)

Submission status: Runtime Error

Solution code:
#import numpy as np

def FindMaxCon(res, water, C, D, E):
  c = 0
  d = 0
  tmpCon = 0
  dp = list([False] * 3001)
  dp[0] = True
  for i in range(3001):
    if(i - C >= 0 and i - D >= 0):
      dp[i] = dp[i - C] or dp[i - D]
    elif(i - C >= 0):
      dp[i] = dp[i - C]
    elif(i - D >= 0):
      dp[i] = dp[i - D]
  tmpSugar = 0
  for i in range(min(res, E * water / 100) + 1):
    if(dp[i]):
      tmpSugar = i
  ans = tmpSugar
  return ans

A, B, C, D, E, F = (map(int, input().split()))
amax = F / (A * 100)
bmax = F / (B * 100)
amax = int(amax)
bmax = int(bmax)
water = 0
sugar = 0
waterAns= 0
sugarAns = 0
con = 0
conAns = 0
for a in range(1, amax + 1):
  for b in range(bmax + 1):
    water = 100 * (a * A + b * B)
    if(water > F):
      continue
    else:
      res = F - water
      tmp = FindMaxCon(res, water, C, D, E)
      sugar = tmp
      con = sugar / water
      if(con > conAns):
        print("if called")
        conAns = con
        waterAns = water
        sugarAns = sugar
answer = str(waterAns + sugarAns) + " " + str(sugarAns)
print(answer)

Submission status: Runtime Error

Solution code:


A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = set()

#y is a list which represents for the volumn of sugar
y = set()

for i in range(F//C+1):
    for j in range((F-C*i)//D+1):
        #if i + j == 0:
            continue
        y.add( i * C + j * D)

for i in range(F//(100 * A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        if i + j == 0:
            continue
        x.add(i * A * 100 + j * B * 100)
#print(x)
#print(y)
ans_sweetwater = 1
ans_sugar = -1
#ans_density = -1
#density = E/(100+E)
#print("density: ",density)
for m in x:
    for n in y:
        #tmp_density = n/(m+n)
        if m + n <= F and m*E/100 >= n and ans_sugar/ans_sweetwater <= n/(m+n):
            ans_sweetwater =  m + n
            ans_sugar = n
            #ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Runtime Error

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range(F-C*i//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D

        if tmp_y <= F:
            y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range(F-(100*A*i)//(100*B)+1):
        if i == j == 0:
            continue

        tmp_x = i * A * 100 + j * B * 100

        if tmp_x <= F:
            x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = 0
ans_density = 0
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and x/100*E >= y and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = [int(n) for n in input().split()]

max_ratio = 0
for cnt_A in [n for n in range(30) if 100*A*n <= F]:
  for cnt_B in [n for n in range(30) if 100*A*cnt_A * 100*B*n <= F]:
    for cnt_C in [n for n in range(1500) if n*C <= E*(A*cnt_A+B*cnt_B) and 100*A*cnt_A + 100*B*cnt_B + n*C <= F]:
      for cnt_D in [n for n in range(1500) if n*D + C*cnt_C <= E*(A*cnt_A + B*cnt_B)and 100*A*cnt_A + 100*B*cnt_B + C*cnt_C + D*n <= F]:
        if (cnt_A!=0 or cnt_B !=0)and max_ratio < (C*cnt_C+D*cnt_D)/(100*A*cnt_A+100*B*cnt_B):
          max_ratio = (C*cnt_C + D*cnt_D)/(100*A*cnt_A+100*B*cnt_B)
          a = 100*A*cnt_A + 100*B*cnt_B
          b = C*cnt_C + D*cnt_D
print(a+b, b)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int,raw_input().split())
lim = f
f /= 100
wl = [False for _ in range(f+1)]
sl = [False for _ in range(f*e+1)]
wl[a] = True
wl[b] = True
sl[c] = True
sl[d] = True

for i in range(f):
    if wl[i] and i+a <= f:
        wl[i+a] = True
    if wl[i] and i+b <= f:
        wl[i+b] = True

for i in range(f*e):
    if sl[i] and i+c <= f*e:
        sl[i+c] = True
    if sl[i] and i+d <= f*e:
        sl[i+d] = True

maxd = 0.0
maxw = 0
maxs = 0
for i,w in enumerate(wl):
    for j,s in enumerate(sl):
        if w and s and i*100+j <= lim:
            if i*e >= j and float(j) / float(100*i+j) > maxd:
                maxd = float(j) / float(100*i + j)
                maxw = i*100
                maxs = j
print maxw+maxs,maxs

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f= map(int, input().split())
2.youeki=0
3.yousitu=0
4.noudo=0
5.n_a=int(f/(100*a))
6. 
7. 
8.for i in range(1+n_a):
9. for j in range(1+int((f-100*i*a)/(100*b))):
10.  for k in range(1+int((f-100*i*a-100*j*b)/c)):
11.   for l in range(1+int((f-100*i*a-100*j*b-k*c)/d)):
12.    S=100.0*a*i+100.0*b*j+c*k+d*l
13.    T=c*k+d*l
14.    if S!=0:
15.     L=100.0*T/S
16.     if S<=f and L<=100*e/(100+e) and L>=noudo:
17.      noudo=L
18.      youeki=S
19.      yousitu=T
20.print(int(youeki),int(yousitu))

Submission status: Runtime Error

Solution code:
def per(a, b):
    if a == 0 or b == 0:
        return 0
    return 100 * b / (a + b)


a, b, c, d, e, f = [int(i) for i in input().split()]
max_sugar = e * f / 100
max_water = f - max_sugar
s = 0
water = set()
check = 0
n = 0
while check <= f:
    while check <= f:
        water.add(check)
        check += b * 100
    check = a*100*n
    n += 1
check = 0
n = 0
sugar_ans = 0
g = 0
for i in water:
    max_sugar = e * i / 100
    while check <= max_sugar and check + i <= f:
        while check <= max_sugar and check + i <= f:
            if g < per(i, check) and i + check <= f:
                sugar_ans = check
                g = per(i, check)
                water_ans = i
            check += d
        check = c * n
        n += 1

print(water_ans + sugar_ans, sugar_ans)

Submission status: Runtime Error

Solution code:
def per(a, b):
    if a == 0 or b == 0:
        return 0
    return 100 * b / (a + b)


a, b, c, d, e, f = [int(i) for i in input().split()]
max_sugar = e * f / 100
max_water = f - max_sugar
s = 0
water = set()
numa = f // a
numb = f // b
for i in range(numa):
    check = 100 * a * i
    if f < check:
        break
    water.add(check)
    for m in range(numb):
        h = check + 100 * b * m
        if f < h:
            break
        water.add(h)
check = 0
n = 0
sugar_ans = 0
g = 0
for i in water:
    max_sugar = e * i /100
    while check <= max_sugar and check + i <= f:
        while check <= max_sugar and check + i <= f:
            if g < per(i, check) and i + check <= f:
                sugar_ans = check
                g = per(i, check)
                water_ans = i
            check += d
        check = c * n
        n += 1

print(water_ans + sugar_ans, sugar_ans)

Submission status: Runtime Error

Solution code:
x =  list(map(int, input().split()))
max_per = 100*(x[4]) / 100
now_max_per = 0
ansSugarWater = 0
ansSugar = 0
for B in range(min(int(x[5]/(100*x[1]))), 31):
    for A in range(min(int((x[5]-100*B*x[1])/(100*x[0]))+ 1), 31):
        now_sugar = 0
        can_sugar = max_per * (x[0]*A + x[1]*B)
        if can_sugar + 100*x[0]*A + 100*x[1]*B > x[5]:
            can_sugar = x[5] - 100*x[0]*A - 100*x[1]*B
        i = [0,0]
        for D in range(min(int(can_sugar / x[3] + 1)), 31):
            for C in range(min(int((can_sugar - D*x[3])/x[2])+ 1, 31)):
                if C*x[2] + D*x[3] > now_sugar:
                    now_sugar = C*x[2] + D*x[3]
                    i = [C, D]
        C = i[0]
        D = i[1]
        if  A == 0 and B == 0:
            continue
        elif C*x[2] + D*x[3] > can_sugar:
            continue
        elif 100*x[0]*A + 100*x[1]*B + x[2]*C + x[3]*D > x[5]:
            continue
        else:
            now_per = 100 * (C*x[2] + D*x[3]) / (100*(A*x[0] + B*x[1]) + C*x[2] + D*x[3])
        if max_per >= now_per > now_max_per :
            now_max_per = now_per
            ansSugarWater = 100 * (A*x[0] + B*x[1]) + C*x[2] + D*x[3]
            ansSugar = C*x[2] + D*x[3]
print("{0} {1}".format(ansSugarWater, ansSugar))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(int(F/(100*max(A,B)))+1):
    for j in range(int(F/(100*min(A,B)))+1):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)
            
for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo//C)+1):
        for j in range(int(howaryo//D)+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Runtime Error

Solution code:
def solve():
    
A, B, C, D, E, F = map(int, input().split())
memo = []

for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                w = (100*A)*a + (100*B)*b
                s = C*c + D*d
                if w+s > F:
                    break
                else:
                    if w/100 * E >= s:
                        memo.append([w+s,s])

print(*sorted(memo, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    w = (100*A)*a + (100*B)*b
                    s = C*c + D*d
                    if w+s > F:
                        break
                    else:
                        if w/100 * E >= s:
                            density = 100* s/(w+s)
                            memo[a,b,c,d] = density
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
            break
 
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
    def i1():
     return int(input())
    def i2():
     return [int(i) for i in input().split()]

    [a,b,c,d,e,f]=i2()
    g=[]
    for i in range(31):
        for j in range(31):
                    ttt=(a*i+b*j)*100
                    tk=min(ttt*e/100,f-ttt)
                    tt=(tk//d)*d+(tk%d//(d-c))*(d-c)
                    t=ttt+tt
                    if t>0 :
                        g.append([(100*tt)/t,t,tt])

    g.sort()
    print(int(g[-1][1]),int(g[-1][2]))

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

[a,b,c,d,e,f]=i2()
g=[[0,100*a,0]]
for i in range(31):
    for j in range(31):
                ttt=(a*i+b*j)*100
                tk=min(ttt*e/100,f-ttt)
                tt=(tk//d)*d+(tk%d//(d-c))*(d-c)
                t=ttt+tt
                if t>0 :
                    g.append([(100*tt)/t,t,tt])

g.sort()
print(int(g[-1][1]),int(g[-1][2]))

Submission status: Runtime Error

Solution code:
    A,B,C,D,E,F=map(int,input().split())
    best_water=0
    best_salt=0
    best_rate=0
    for i in range(30//A+1):#Aの投入数
      for j in range(30//B+1):#Bの投入数
        water=(i*A+j*B)*100
        if water<=F and water:
          max_salt=(i*A+j*B)*E
          for k in range(max_salt//C+1):#Cを何個使うか
            l=(max_salt-C*k)//D#Dは何個つかえるか
            salt=k*C+l*D
            rate=100*salt/(water+salt)
            if rate>best_rate and salt<=max_salt and rate<=E and water+salt<=F:
              best_rate=rate
              best_salt=salt
              best_water=water
    print(best_water+best_salt,best_salt)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
x=[]
y=[]
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=A*i+B*j
    if water<=F: x+=[water]
for i in range(31):#Aの投入数
  for j in range(31):#Bの投入数
    salt=C*i+D*j
    y+=[salt]
best_water=0
best_salt=0
best_rate=0
for water in x:
  for salt in y:
    rate=100*salt/(water+salt)
    if rate>best_rate and rate<=E and water+salt<=F:
      best_rate=rate
      best_salt=salt
      best_water=water
print(best_water+best_salt,best_salt)

Submission status: Runtime Error

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

def G(a, b):
  while b > 0:
    a, b = b, a%b
  return a
def L(a, b):
  return a * b // G(a, b)

caps = {(N * 100 * A + M * 100 * B) for N in range(1 + F // (100 * A)) for M in range(1 + (F - N * 100 * A) // (100 * B))}

res = [0,0,0]
for water in caps:
    if water == 0: continue
    capp = min(F - water, E * water // 100)
    resug = capp % L(C, D)  
    cosug = capp - resug
    sugers = [(N * C + M * D + cosug) for N in range(resug // C + 1) for M in range((resug - N * C)//D + 1)]
    suger = max(sugers)
    ratio = suger / (water + suger)
    if res[0] < ratio: res = [ratio, suger + watter, suger] 


print(res[1], res[2])

Submission status: Runtime Error

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

cap = 0
sug = 0

def G(a, b):
  while b > 0:
    a, b = b, a%b
  return a
def L(a, b):
  return a * b // G(a, b)


caps = {(N * 100 * A + M * 100 * B) for N in range(1 + F // (100 * A)) for M in range(1 + (F - N * 100 * A) // (100 * B))}
print(caps)

res = [0,0,0]
for water in caps:
    if water == 0: continue
    capp = min(F - water, E * water // 100)
    resug = capp % L(C, D)  
    cosug = capp - resug
    sugers = [(N * C + M * D + cosug) for N in range(resug // C + 1) for M in range((resug - N * C)//D + 1)]
    print(water, sugers)
    suger = max(sugers)
    ratio = suger / (water + suger)
    if res[0] < ratio: res = [ratio, suger + watter, suger] 


print(res[1], res[2])

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
best_water=0
best_salt=0
best_rate=0
for i in range(30//A+1):#Aの投入数
  for j in range(30//B+1):#Bの投入数
    water=(i*A+j*B)*100
    if water<=F and water:
      max_salt=(i*A+j*B)*E
      for k in range(max_salt//C+1):#Cを何個使うか
        l=(max_salt-C*k)//D#Dは何個つかえるか
        salt=k*C+l*D
        rate=100*salt/(water+salt)
        if rate>best_rate and rate=<E and water+salt <=F:
          best_rate=rate
          best_salt=salt
          best_water=water
print(best_water+best_salt,best_salt)

Submission status: Runtime Error

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

def node(w,s):
    return s/w

w,s = 0,0

w += a

nodelist = []
nodelistapd = nodelist.append
nodedict = {}

enode = node(100+e, e)

while(1):
    if w >= f:break
    if node(w+d,s+d) <= enode:
        s += d
        w += d
    elif node(w+c,s+c) <= enode:
        s += c
        w += c
    else:
        nodelistapd(node(w,s))
        nodedict[node(w,s)] = (w,s)
        if node(w+b,s) not in nodelist:
            w += b
        elif node(w+a,s) not in nodelist:
            w += a
        else:
            break
        
ansnode = nodedict[max(nodelist)]
print("{} {}".format(ansnode[0],ansnode[1]))

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = [int(x) for x in input().strip().split()]
a *= 100
b *= 100
if f < a + c:
    print("0 0")
    raise SystemExit

water_cands = set()
t = 0
while t <= f:
    water_cands.add(t)
    u = t + b
    while u <= f:
        water_cands.add(u)
        u += b
    t += a

rat, wat, sug = 0.0, 0, 0
for w in water_cands:
    suger_limit = min(f - w, w // 100 * e)
    suger_max = 0
    t = 0
    while t <= suger_limit:
        if suger_max < t:
            suger_max = t
        u = t + d
        while u <= suger_limit:
            if suger_max < u:
                suger_max = u
            u += d
        t += c
    if suger_max / (suger_max + w) > rat:
        rat = suger_max / (suger_max + w)
        wat = w
        sug = suger_max

print(wat + sug, sug)