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: Wrong Answer

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

mz_a = f//(a*100)
mz_b = f//(b*100)

st_max = f*e/(100+e)

st_c = int(st_max//c)
st_d = int(st_max//d)
ans1 = 0
ans2 = [0,0]
for i in range(mz_a+1):#30以下
    wat_rem = f/100-i*a
    wat_rem_b = int(wat_rem/b)
    for j in range(wat_rem_b+1):#30以下
        for k in range(st_c):#
            wat = i*a + j*b
            l = max((wat*e-k*c)//d,0)
            sug = k*c + l*d
            #print(wat,l,sug)
            if wat>0 and wat*100+sug <=f:
                if ans1*wat <= sug and sug <=e*wat:
                    ans1 =sug/wat
                    ans2 =[sug,wat]
                
print(ans2[0]+ans2[1]*100, ans2[0])

Submission status: Wrong Answer

Solution code:
import math
a,b,c,d,e,f=map(int,input().split())
checklist=[]
for num1 in range(f+1):

    for num2 in range(f+1):
        if (100*a)*(num1)+(100*b)*(num2)<=f and [num1,num2]!=[0,0] and num1*a*100+num2*b*100  not in checklist:
            checklist.append(num1*a*100+num2*b*100)
sugarlist=[]
for i in range(f+1):
    for j in range(f+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*(x/y)<=e:
            if x/y>=ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            if ratio==e/100:
                break      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Submission status: Wrong Answer

Solution code:
import math
a,b,c,d,e,f=map(int,input().split())
checklist=[]
for num1 in range(f+1):
    #num1=0,1,2,....use//a
    for num2 in range(f+1):
        #num2=0,1,2.....use//b
        if (100*a)*(num1)+(100*b)*(num2)<=f and [num1,num2]!=[0,0] and num1*a*100+num2*b*100  not in checklist:
            checklist.append(num1*a*100+num2*b*100)
sugarlist=[]
for i in range(f+1):
    for j in range(f+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*(x/y)<=e:
            if x/y>ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            if 100*(x/y)==e:
                ratio=x/y
                maxsugar=x
                good=x+y
                break      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Submission status: Wrong Answer

Solution code:
import math
a,b,c,d,e,f=map(int,input().split())
#a*x+b*y<f/100なる(x,y)について隈無く調べる
checklist=[]
for num1 in range((f//(100*a))+1):
    #num1=0,1,2,....use//a
    for num2 in range((f//(100*b))+1):
        #num2=0,1,2.....use//b
        if a*(num1)+b*(num2)<=f/100 and [num1,num2]!=[0,0] and num1*a*100+num2*b*100  not in checklist:
            checklist.append(num1*a*100+num2*b*100)
sugarlist=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*(x/y)<=e:
            if x/y>ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            if 100*(x/y)==e:
                ratio=x/y
                maxsugar=x
                good=x+y
                break      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Submission status: Wrong Answer

Solution code:
import math
a,b,c,d,e,f=map(int,input().split())
#a*x+b*y<f/100なる(x,y)について隈無く調べる
checklist=[]
for num1 in range((f//(100*a))+1):
    #num1=0,1,2,....use//a
    for num2 in range((f//(100*b))+1):
        #num2=0,1,2.....use//b
        if a*(num1)+b*(num2)<=f/100 and [num1,num2]!=[0,0] and num1*a*100+num2*b*100  not in checklist:
            checklist.append(num1*a*100+num2*b*100)
sugarlist=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*(x/y)<=e:
            if x/y>ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            if x/y==e:
                ratio=x/y
                maxsugar=x
                good=x+y
                break      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Submission status: Wrong Answer

Solution code:
import math
a,b,c,d,e,f=map(int,input().split())
#a*x+b*y<f/100なる(x,y)について隈無く調べる
checklist=[]
for num1 in range((f//(100*a))+1):
    for num2 in range((f//(100*b))+1):
        if a*(num1)+b*(num2)<=f/100 and [num1,num2]!=[0,0] and num1*a*100+num2*b*100  not in checklist:
            checklist.append(num1*a*100+num2*b*100)
sugarlist=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*(x/y)<=e:
            if x/y>ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            if 100*(x/y)==e:
                ratio=x/y
                maxsugar=x
                good=x+y
                print(x)
                print(y)
                break      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar) 
print(checklist)
print(sugarlist)

Submission status: Wrong Answer

Solution code:
import math
a,b,c,d,e,f=map(int,input().split())
#a*x+b*y<f/100なる(x,y)について隈無く調べる
checklist=[]
for num1 in range((f//(100*a))+1):
    #num1=0,1,2,....use//a
    for num2 in range((f//(100*b))+1):
        #num2=0,1,2.....use//b
        if a*(num1)+b*(num2)<=f/100 and [num1,num2]!=[0,0] and num1*a*100+num2*b*100  not in checklist:
            checklist.append(num1*a*100+num2*b*100)
sugarlist=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*(x/y)<=e:
            if x/y>ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            if x/y==e:
                ratio=x/y
                maxsugar=x
                good=x+y
                print(x)
                print(y)
                break      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Submission status: Wrong Answer

Solution code:
import math
a,b,c,d,e,f=map(int,input().split())
#a*x+b*y<f/100なる(x,y)について隈無く調べる
use=math.floor(f/100)
checklist=[]
for num1 in range((use//a)+1):
    #num1+1=1,2,....use//a
    for num2 in range((use//b)+1):
        #num2+1=1,2.....use//b
        if a*(num1)+b*(num2)<f/100 and [num1,num2]!=[0,0] and num1*1*100+num2*b*100  not in checklist:
            checklist.append(num1*a*100+num2*b*100)
            #ここまでの計算量 :10^2
#水入れの条件について調べる
sugarlist=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)
maxsugar=0
ratio=0
good=0
            
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*(x/y)<=e:
            if x/y>ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            if x/y==e:
                ratio=x/y
                maxsugar=x
                good=x+y
                print(x)
                print(y)
                break      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
V = 0
ans = ()
for i in range(F//(A*100)+1):
  for j in range(F//(B*100)+1):
    m = A*i + B*j
    m = m*100
    if m>F or m==0:
      continue
    lim = min(m*E//100, F-m)
    
    l = lim
    w = 0
    z = 0
    for x in range(lim//C+1):
      for y in range(lim//D+1):
        n = x*C+y*D
        if n>lim:
          continue
        if lim-n<l:
          l = lim-n
          w = x
          z = y
    s = w*C+z*D
    v = 100*s/(m+s)
    if v>V:
      ans = (m+s,s)
      V = v
if ans==():
  print(F, 0)
else:
  print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
V = 0
ans = ()
for i in range(F//(A*100)+1):
  for j in range(F//(B*100)+1):
    m = A*i + B*j
    m = m*100
    if m>F or m==0:
      continue
    lim = min(m*E//100, F-m)
    
    l = lim
    w = 0
    z = 0
    for x in range(lim//C+1):
      for y in range(lim//D+1):
        n = x*C+y*D
        if n>lim:
          continue
        if lim-n<l:
          l = lim-n
          w = x
          z = y
    s = w*C+z*D
    v = 100*s/(m+s)
    if v>V:
      ans = (m+s,s)
      V = v
print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
V = 0
ans = ()
for i in range(F//(A*100)+1):
  for j in range(F//(B*100)+1):
    m = A*i + B*j
    m = m*100
    if m>F or m==0:
      continue
    lim = min(m*E//100, F-m)
    
    l = lim
    w = 0
    z = 0
    for x in range(lim//C+1):
      for y in range(lim//D+1):
        n = x*C+y*D
        if n>lim:
          continue
        if lim-n<l:
          l = lim-n
          w = x
          z = y
    s = w*C+z*D
    v = 100*s//(m+s)
    if v>V:
      ans = (m+s,s)
      V = v
print(*ans)

Submission status: Wrong Answer

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

for i in range(1, (F // (100 * A) + 1)):
    for j in range(F // (100 * B) + 1):
        a = 100 * A * i + 100 * B * j
        if a > F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a) // D + 1):
                b = k * C + l * D
                if (i + j) * E < b or a + b > F:
                    break
                c.append(100 * b / (a + b))
                ans_list.append([a + b, b])

ans = ans_list[c.index(max(c))]

print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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

for i in range(1, A + 1):
    for j in range(B + 1):
        a = 100 * i + 100 * j
        if a > F:
            break
        for k in range(F // (C + 1) + 1):
            for l in range(F // (D + 1) + 1):
                b = k * C + l * D
                if (i + j) * E < b or a + b > F:
                    break
                c.append(100 * b / (a + b))
                ans_list.append([a + b, b])

ans = ans_list[c.index(max(c))]

print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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

waters = []
sugars = []

for w in range(f // 100):
    for i in range(0, w+1, a):
        if (w - i) % b == 0:
            waters.append(w)
            break
for s in range(f):
    for i in range(0, s+1, c):
        if (s - i) % d == 0:
            sugars.append(s)
            break

answ = 1
anss = 0

for w in waters:
    for s in sugars:
        if 100 * w + s > f:
            continue
        if s > e * w:
            continue
        if w == 0:
            continue
        if s / w > anss / answ:
            answ = w
            anss = s
print(answ*100+anss, anss)

Submission status: Wrong Answer

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

waters = []
sugars = []

for w in range(f // 100):
    for i in range(0, w, a):
        if (w - i) % b == 0:
            waters.append(w)
            break
for s in range(f):
    for i in range(0, s, c):
        if (s - i) % d == 0:
            sugars.append(s)
            break

answ = 1
anss = 0

for w in waters:
    for s in sugars:
        if 100 * w + s > f:
            continue
        if s > e * w:
            continue
        if w == 0:
            continue
        if s / w > anss / answ:
            answ = w
            anss = s
print(answ*100+anss, anss)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans_sw = 1
ans_s = 0
for a in range(F//(100*A)+1):
  for b in range(F//(100*B)+1):
    if 100*A*a + 100*B*b > F or 100*A*a+100*B*b == 0:
      continue
    for c in range((A*a+B*b)*E+1):
      for d in range((A*a+B*b)*E+1):
        sw = 100*A*a+100*B*b+C*c+D*d
        s = C*c+D*d
        if 0 < sw <= F and s <= (A*a+B*b)*E and ans_s/ans_sw < s/sw:
          ans_s = s
          ans_sw = sw
if ans_sw == 1:
  print(0 ,0)
else:
  print(ans_sw, ans_s)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans_sw = 1
ans_s = 0
for a in range(F//(100*A)+1):
  for b in range(F//(100*B)+1):
    if 100*A*a + 100*B*b > F or 100*A*a+100*B*b == 0:
      continue
    for c in range((A*a+B*b)*E+1):
      for d in range((A*a+B*b)*E+1):
        sw = 100*A*a+100*B*b+C*c+D*d
        s = C*c+D*d
        if 0 < sw <= F and s <= (A*a+B*b)*E and ans_s/ans_sw < s/sw:
          ans_s = s
          ans_sw = sw
print(ans_sw, ans_s)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
A, B, C, D, E, F = [int(x) for x in input().split()]
A *= 100
B *= 100
d = defaultdict(lambda: False)
d2 = defaultdict(lambda: False)
dd2 = defaultdict(lambda: False)

ret = [0, 0, 0]

def dp2(w, s):
  global ret
  total_weight = w + s
  if dd2[(w, s)] != False:
    return d2[(w, s)]
  else:
    dd2[(w, s)] = True
  if (s / w) > E / 100:
    d2[(w, s)] = 0
    return 0
  else:
    d2[(w, s)] = 100 * s / (s + w)
    if d2[(w, s)] > ret[0]:
      ret = [d2[(w, s)], w + s, s]
  if total_weight + C <= F:
    dp2(w, s + C)
  if total_weight + D <= F:
    dp2(w, s + D)
  
def dp(w):
  if d[w]:
    return 0
  dp2(w, 0)
  d[w] = True
  if w + A <= F:
    dp(w + A)
  if w + B <= F:
    dp(w + B)
  return 0

dp(min(A, B))
print(ret[1],ret[2])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
A, B, C, D, E, F = [int(x) for x in input().split()]
A *= 100
B *= 100
d = defaultdict(lambda: False)
d2 = defaultdict(lambda: False)

ret = [0, 0, 0]

def dp2(w, s):
  global ret
  total_weight = w + s
  if d2[(w, s)] != False:
    return d2[(w, s)]
  if (s / w) > E / 100:
    d2[(w, s)] = 0
    return 0
  else:
    d2[(w, s)] = 100 * s / (s + w)
    if d2[(w, s)] > ret[0]:
      ret = [d2[(w, s)], w + s, s]
  if total_weight + C <= F:
    dp2(w, s + C)
  if total_weight + D <= F:
    dp2(w, s + D)
  
def dp(w):
  if d[w]:
    return 0
  dp2(w, 0)
  d[w] = True
  if w + A <= F:
    dp(w + A)
  if w + B <= F:
    dp(w + B)
  return 0

dp(min(A, B))
print(ret[1],ret[2])

Submission status: Wrong Answer

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

maxs = 0
maxw = 1
for i in range(0,F//100+1,B):
  for j in range(0,F//100-i+1,A):
    if i+j == 0:
      continue
    w = (i+j)*100
    for k in range(0,min(F-w,E*w//100)+1,D):
      l = min((F-w-k)//C * C,(E*w//100-k)//C * C)
      l = max(l,0)
      s = k+l
      if s+w > F or E*w//100 < s:
        continue
      #print(i,j,k,l,s/(s+w))
      if maxs/(maxs+maxw) < s/(s+w):
        maxs = s
        maxw = w
print(maxs+maxw,maxs)

Submission status: Wrong Answer

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

maxs = 0
maxw = 1
for i in range(0,F//100+1,B):
  for j in range(0,F//100-i+1,A):
    if i+j == 0:
      continue
    w = (i+j)*100
    for k in range(0,min(F-w,E*w//100)+1,D):
      l = min((F-w-k)//C * C,(E*w//100-k)//C * C)
      l = max(l,0)
      s = k+l
      #print(i,j,k,l,s/(s+w))
      if maxs/(maxs+maxw) < s/(s+w):
        maxs = s
        maxw = w
print(maxs+maxw,maxs)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
res = (100, 0)
for aa in range(0, f + 1, 100 * a):
    for bb in range(0, f + 1, 100 * b):
        w = aa + bb
        if w == 0 or w >= f:
            continue
        r = f - w
        for cc in range(0, r + 1, c):
            for dd in range(0, r + 1, d):
                s = cc + dd
                t = w + s
                if t > f or 100 * s > e * w:
                    continue
                if s * res[0] > res[1] * t:
                    res = (t, s)
print(*res)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
res = (100, 0)
for aa in range(0, f + 1, 100 * a):
    for bb in range(0, f + 1, 100 * b):
        w = aa + bb
        if w == 0 or w > f:
            continue
        r = f - w
        for cc in range(0, r + 1, c):
            for dd in range(0, r + 1, d):
                s = cc + dd
                if s + w > f or 100 * s > e * w:
                    continue
                if s * res[0] > res[1] * (s + w):
                    res = (w + s, s)
print(*res)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
res = (100, 0)
m = 0
for aa in range(0, f + 1, 100 * a):
    for bb in range(0, f + 1, 100 * b):
        w = aa + bb
        if w == 0 or aa + bb > f:
            continue
        r = f - w
        for cc in range(0, r + 1, c):
            for dd in range(0, r + 1, d):
                s = cc + dd
                if s + w > f or 100 * s > e * w:
                    continue
                mm = s / w
                if mm > m:
                    res = (w + s, s)
                    m = mm
print(*res)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
res = (100, 0)
m = 0
for aa in range(0, f, 100 * a):
    for bb in range(0, f, 100 * b):
        w = aa + bb
        if w == 0 or aa + bb > f:
            continue
        r = f - w
        for cc in range(0, r, c):
            for dd in range(0, r, d):
                s = cc + dd
                if s + w > f or 100 * s > e * w:
                    continue
                mm = s / w
                if mm > m:
                    res = (w + s, s)
                    m = mm
print(*res)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [-1] * (F+1)
for b in range(30):
  for a in range(30):
    water = 100*A*a + 100*B*b
    if water > F:
      continue
    dp[water] = 0
dp[0] = -1
for d in range(100):
  for c in range(100):
    for water in range(F):
      sugar = C*c + D*d
      if dp[water] != -1 and water+sugar  <= F and dp[water] + sugar <= (water-dp[water])*E//100:
        dp[water+sugar] = max(dp[water+sugar], dp[water] + sugar)
max_p = 0
max_ws = 0
max_s = 0
for ws in range(1, F):
  if max_p < dp[ws]/ws:
    max_ws = ws
    max_s = dp[ws]
    max_p = dp[ws]/ws
print(max_ws, max_s)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
sugar = 0
s_water = 100
for a in range(F//(100*A)+2):
  for b in range((F-100*A*a)//(100*B)+2):
    if a == 0 and b == 0:
      continue
    f = F - 100*(A*a+B*b)
    max_s = min((A*a+B*b)*E, f)
    for c in range(max_s//C+1):
      d = (max_s-c*C)//D
      sugar_temp = c*C+d*D
      s_water_temp = 100*(A*a+B*b) + sugar_temp
      if sugar_temp/s_water_temp > sugar/s_water:
        sugar = sugar_temp
        s_water = s_water_temp
print(s_water, sugar)

Submission status: Wrong Answer

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


A, B, C, D, E, F =  map(int, sys.stdin.readline().split())

def bluteforce(limit):
    suger = 0
    for c in range(limit // C + 1):
        for d in range(limit // D + 1):
            tmpsum = c * C + d * D
            if tmpsum > limit:
                break
            suger = max(suger,tmpsum)
    return suger

def greedy(limit):
    suger = 0

    while True:
        if limit >= D:
            limit -= D
            suger += D
            continue
        elif limit >= C:
            limit -= C
            suger += C
            continue
        else:
            return suger

a_m = 0
a_s = 0
dense = 0
for a in range(1, 31):
    for b in range(0, 31):
        water = (100 * a * A) + (100 * b * B)
        if water >= F:
            break
        wei_lim = F - water
        # suger = greedy(min((a * A + b * B) * E, wei_lim))
        suger = bluteforce(min((a * A + b * B) * E, wei_lim))
        mass = water + suger
        d = (suger / mass) * 100
        if d > dense:
            # print(suger, water, a, b, d)
            dense = d
            a_m = mass
            a_s = suger

print(a_m, a_s)

Submission status: Wrong Answer

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


A, B, C, D, E, F =  map(int, sys.stdin.readline().split())

def greedy(limit):
    suger = 0
    while True:
        if limit >= D:
            limit -= D
            suger += D
            continue
        elif limit >= C:
            limit -= C
            suger += C
            continue
        else:
            return suger

a_m = 0
a_s = 0
dense = 0
for a in range(1, 31):
    for b in range(0, 31):
        suger = greedy((a + b) * E)
        water = (100 * a) + (100 * b)
        mass = water + suger
        if mass > F:
            break
        d = (suger / mass) * 100
        # print(suger, water, d)
        if d > dense:
            dense = d
            a_m = mass
            a_s = suger

print(a_m, a_s)

Submission status: Wrong Answer

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

M = 0
S = 0
N = 30
ansp = 0
tmpM = 0
tmpS = 0
SUGAR = [0]*3001
SUGAR[0] = 1
for i in range(1,3001):
    if i - C >= 0:
        if SUGAR[i-C] == 1:
            SUGAR[i] = 1
    if i - D >= 0:
        if SUGAR[i-D] == 1:
            SUGAR[i] = 1

for i in range(31):
    for j in range(31-i):
        tmpM = 100*A*i+100*B*j
        maxS = E*(A*i+B*j)
        if tmpM != 0 and tmpM <= F:
            for k in range(E*(A*i+B*j)+1):
                l = E*(A*i+B*j) - k
                #print(l)
                if SUGAR[l] == 1 and l+tmpM <= F:
                    tmpS = l
                    break
            if tmpS/(tmpM+tmpS) > ansp:
                ansp = tmpS/(tmpM+tmpS)
                M = tmpM
                S = tmpS
print(*[M+S,S])

Submission status: Wrong Answer

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

limit = e / (100 + e)

mx = 0
ans = [0, 0]

a_max = f // (100 * a)
for a_i in range(a_max + 1):
    ag = 100 * a * a_i
    bcdg_max = f - ag
    b_max = bcdg_max // (100 * b)
    for b_i in range(b_max + 1):
        bg = 100 * b * b_i
        if ag + bg == 0:
            continue
        cdg_max = bcdg_max - bg
        c_max = cdg_max // c
        for c_i in range(c_max + 1):
            cg = c * c_i
            dg_max = cdg_max - cg
            d_max = dg_max // d
            for d_i in range(d_max + 1):
                dg = d * d_i
                tmp = (cg + dg) / (ag + bg + cg + dg)
                if mx < tmp <= limit:
                    mx = tmp
                    ans = [ag + bg + cg + dg, cg + dg]

print(*ans)

Submission status: Wrong Answer

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

limit = e / 100

mx = 0
ans = [0, 0]

a_max = f // (100 * a)
for a_i in range(a_max + 1):
    ag = 100 * a * a_i
    bcdg_max = f - ag
    b_max = bcdg_max // (100 * b)
    for b_i in range(b_max + 1):
        bg = 100 * b * b_i
        if ag + bg == 0:
            continue
        cdg_max = bcdg_max - bg
        c_max = cdg_max // c
        for c_i in range(c_max + 1):
            cg = c * c_i
            dg_max = cdg_max - cg
            d_max = dg_max // d
            for d_i in range(d_max + 1):
                dg = d * d_i
                tmp = (cg + dg) / (ag + bg + cg + dg)
                if mx < tmp <= limit:
                    mx = tmp
                    ans = [ag + bg + cg + dg, cg + dg]

print(*ans)

Submission status: Wrong Answer

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

limit = e / 100

mx = 0
ans = [0, 0]

a_max = 3000 // (100 * a)
for a_i in range(a_max + 1):
    ag = 100 * a * a_i
    bcdg_max = f - ag
    b_max = bcdg_max // (100 * b)
    for b_i in range(b_max + 1):
        bg = 100 * b * b_i
        if ag + bg == 0:
            continue
        cdg_max = bcdg_max - bg
        c_max = cdg_max // c
        for c_i in range(c_max + 1):
            cg = c * c_i
            dg_max = cdg_max - cg
            d_max = dg_max // d
            for d_i in range(d_max + 1):
                dg = d * d_i
                tmp = (cg + dg) / (ag + bg + cg + dg)
                if mx < tmp <= limit:
                    mx = tmp
                    ans = [ag + bg + cg + dg, cg + dg]

print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

A = A * 100
B = B * 100

ans = 0
m = (0, 0)
for i in range(31):
    for j in range(31):
        for k in range(60):
            for l in range(60):
                wa = (A * i) + (B * j)
                su = (C * k) + (D * l)

                if wa + su > F:
                    continue

                if (wa // 100 * E) < su:
                    continue

                if wa == 0:
                    continue

                t = (su * 100) / (wa + su)
                if ans < t:
                    ans = t
                    m = (wa, su)

print(sum(m), m[1])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

ans = 0
m = 0
for i in range(31):
    for j in range(31):
        for k in range(60):
            for l in range(60):
                wa = (A * 100 * i) + (B * 100 * j)
                su = (C * k) + (D * l)

                if wa + su > F:
                    continue

                if (wa // 100 * E) < su:
                    continue

                if wa == 0:
                    continue

                t = (su * 100) / (wa + su)
                if ans < t:
                    ans = t
                    m = wa + su

print(m, int(m * ans / 100))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

ans = 0
m = 0
for i in range(31):
    for j in range(31):
        for k in range(50):
            for l in range(50):
                wa = (A * 100 * i) + (B * 100 * j)
                su = (C * k) + (D * l)

                if wa + su > F:
                    continue

                if (wa // 100 * E) < su:
                    continue

                if wa == 0:
                    continue

                t = (su * 100) / (wa + su)
                if ans < t:
                    ans = t
                    m = wa + su

print(m, int(m * ans / 100))