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())
water = [False for _ in range(31)]
water[0] = True
for g in [a, b]:
    for i in range(31):
        if i - g < 0:
            continue
        elif water[i - g]:
            water[i] = True
            
salt = [False for _ in range(3001)]
salt[0] = True
for g in [c, d]:
    for i in range(3001):
        if i - g < 0:
            continue
        elif salt[i - g]:
            salt[i] = True

water_cand = []
for i, tf in enumerate(water):
    if tf:
        water_cand.append(i * 100)
salt_cand = []
for i, tf in enumerate(salt):
    if tf:
        salt_cand.append(i)
        
ans = [0, 0]
max_ratio = 0
for w in water_cand:
    if w == 0:
        continue
    for s in salt_cand:
        if w + s > f:
            break
        if w // 100 * e < s:
            break
        ratio = 100 * s / (w + s)
        if max_ratio < ratio:
            max_ratio = ratio
            ans = [w + s, s]
print(*ans)

Submission status: Wrong Answer

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

per = 0.0
ans = salt = w = s = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f + 1, 100 * b):
        w = i + j
        if w > f: break
        for k in range(0, f + 1, c):
            if w + k > f: break
            for l in range(0, f + 1, d):
                w = i + j
                s = k + l
                if w + s > f: break
                if s <= (w // 100) * e:
                    if 0 < s + w <= f:
                        if per < s / (s + w):
                            per = s / (s + w)
                            ans = w + s
                            salt = s
print(ans,salt)

Submission status: Wrong Answer

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

dp=[-1]*(f + 1)
dp[0]=0
salt_dp = [-1]*(f + 1)
salt_dp[0] = 1
for i in range(f):
  if salt_dp[i] != 1:
    continue
  for k in [c, d]:
    if i + k > f:
      continue
    salt_dp[i + k] = 1

for i in range(f+1):
  if dp[i] == -1:
    continue
  for j in [a, b]:
    water = i + 100*j
    if water > f:
      continue
    dp[water] = 0
    salt_max = water * e / 100
    for k in range(int(salt_max),0,-1):
      if salt_dp[k] == 1:
        break
    if water + k <= f:
      dp[water] = max(dp[water], k)
ans = 0
for i in range(f+1):
  if dp[i] > 0:
    ans = i
if ans != 0:
  print(dp[ans] + ans, dp[ans])
else: 
  print(100 * min(a,b), 0)

Submission status: Wrong Answer

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):
  if dp[i] == -1:
    continue
  for j in [a, b]:
    water = i + 100*j
    if water > f:
      continue
    dp[water] = 0
    salt_max = water * e / 100
    dd = int(salt_max - dp[i])
    dp_s = [0] * (dd + 1)
    dp_s[0] = 1
    for pp in range(dd + 1):
      if dp_s[pp] == 0:
        continue
      for k in [c, d]:
        if pp+k > dd:
          continue
        dp_s[pp+k] = 1
    sm = 0
    for index,dp_i in enumerate(dp_s):
      if dp_i != 0:
        sm = index
    if water + sm + dp[i] <= f:
      dp[water] = max(dp[water], sm + dp[i])
ans = 0
for i in range(f+1):
  if dp[i] > 0:
    ans = i
if ans != 0:
  print(dp[ans] + ans, dp[ans])
else: 
  print(100 * min(a,b), 0)

Submission status: Wrong Answer

Solution code:
def main():
    a,b,c,d,e,f = map(int,input().split())
    ans = []
    for i in range(f//a//100+1):
        for j in range((f-100*a*i)//b//100+1):
            if a*i*100+b*j*100 < f:
                ans.append([i,j])
    ans = ans[1:]
    D = 0
    A = [0,0]
    for an in ans:
        m = a*100*an[0] + b*100*an[1]
        slv = e*m//100
        M = 0
        for i in range(min(f-m,slv)//c+1):
            for j in range((min(f-m,slv)-c*i)//d+1):
                if i*c+d*j <= min(slv,f-m):
                    if M < i*c+d*j:
                        M = i*c+d*j
        den = M/(m+M)
        if den>D:
            D = den
            A = [m+M,M]
    print(' '.join([str(a) for a in A]))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from itertools import product
from collections import namedtuple
A, B, C, D, E, F = map(int, input().split())

r100 = lambda x: range(F//(100*x)+1)
cct = 0
sw = namedtuple('sw', ['suger', 'water']) #suger_water
ans = sw(0, 0)
for a, b in product(r100(A), r100(B)):
    water = (a * A + b * B) * 100
    if water > F or water == 0:
        continue
    r = lambda x: range((F-water)//x+1)
    for c, d in product(r(C), r(D)):
        suger = c * C + d * D
        if  water + suger > F:
            continue

        if suger * 100 > water * E:
            continue
        
        if water+suger == 0:
            continue

        if cct < 100 * suger/(suger+water):
            cct = 100 * suger/(suger+water)
            ans = sw(suger, water)

print(ans.suger+ans.water, ans.suger)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0,31):
    for bt in range(0,31-at):
        water = (at * a + bt * b) * 100
        if water > f:
            continue

        # 溶け残らないように砂糖を選ぶ
        maxsugar = water * e // 100
        for ct in range(0, maxsugar//c + 1):
            for dt in range(0, (maxsugar-ct*c)//d + 1):
                sugar = ct * c + dt * d

                if 0 < sugar + water <= f and sugar <= (at * a + bt * b) * e:
                    # 水１００に対して溶けている砂糖の量
                    n = 100 * sugar // water
                    if n == e:
                        print(water + sugar, sugar)
                        exit()
                    if n > maxn:
                        ans = water + sugar, sugar
                        maxn = n
print(*ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0,31):
    for bt in range(0,31-at):
        water = (at * a + bt * b) * 100
        if water > f:
            continue

        # 溶け残らないように砂糖を選ぶ
        maxsugar = water * e // 100
        for ct in range(0, maxsugar//c + 1):
            for dt in range(0, (maxsugar-ct*c)//d + 1):
                sugar = ct * c + dt * d

                if 0 < sugar + water <= f and sugar <= (at * a + bt * b) * e:
                    # 水１００に対して溶けている砂糖の量
                    n = 10 * 100 * sugar // water
                    if n == e * 10:
                        print(water + sugar, sugar)
                        exit()
                    if n > maxn:
                        ans = water + sugar, sugar
                        maxn = n
print(*ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = list(map(int, input().split()))
maxn = 0
ans = ()
for at in range(0,31):
    for bt in range(0,31-at):
        water = (at * a + bt * b) * 100
        if water > f:
            continue

        # 溶け残らないように砂糖を選ぶ
        maxsugar = water * e // 100
        for ct in range(0,maxsugar//c + 1):
            for dt in range(0,maxsugar-ct*c//d + 1):
                sugar = ct * c + dt * d

                if 0 < sugar + water <= f and sugar <= (at * a + bt * b) * e:
                    # 水１００に対して溶けている砂糖の量
                    n = 100 * sugar / water
                    if n == e:
                        print(water + sugar, sugar)
                        exit()
                    if n > maxn:
                        ans = water + sugar, sugar
                        maxn = n
print(*ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = list(map(int, input().split()))
maxn = 0
ans = ()
for at in range(0,31):
    for bt in range(0,31):
        for ct in range(0,31):
            for dt in range(0,31):
                sugar = ct * c + dt * d
                water = (at * a + bt * b) * 100
                if 0 < sugar + water <= f and sugar <= (at * a + bt * b) * e:
                    n = 100 * sugar / (water + sugar)
                    if n > maxn:
                        maxn = n
                        ans = water + sugar, sugar
print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
perc = 0.0
ans = [0, 0]
op = [0, 0, 0, 0]
a = 0
while 100 * a <= F:
  b = 0
  while 100 * (a + b) <= F:
    c = 0
    while 100 * (a + b) + c <= F:
      if c > (a + b) * E:
        break
      d = 0
      while 100 * (a + b) + c + d <= F:
        if c + d > (a + b) * E:
          break
        if a == b == c == d == 0:
          break
        p = (c + d) * 1.0 / (100 * (a + b) + c + d)
        if p > perc:
          perc = p
          ans = [100 * (a + b) + c + d, c + d]
          op = [a, b, c, d]
        d += D
      c += C
    b += B
  a += A
print(str(ans[0]) + " " + str(ans[1]))

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D, E, F = map(int, input().split())
    ans = 0
    sugar = 0
    sugar_water = 0
    for a in range(F // (A * 100) + 1):
        for b in range((F - 100 * A * a) // (B * 100) + 1):
            for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
                for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                    x = a * A + b * B
                    y = c * C + d * D
                    if x == 0:
                        continue
                    if x * E >= y and ans < (100 * y)/(x*100+y):
                        ans = (100 * y)/(x*100+y)
                        sugar = y
                        sugar_water = 100 * x + y
    print(sugar_water,sugar)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D, E, F = map(int, input().split())
    ans = 0
    sugar = 0
    sugar_water = 0
    for a in range(F // (A * 100) + 1):
        for b in range((F - 100 * A * a) // (B * 100) + 1):
            for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
                for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                    x = a * A + b * B
                    y = c * C + d * D
                    if x == 0:
                        continue
                    if x*100+y == 0:
                        continue
                    if x * E >= y and ans < (100 * y)/(x*100+y):
                        ans = (100 * y)/(x*100+y)
                        sugar = y
                        sugar_water = 100 * x + y
    print(sugar_water,sugar)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
noudo=0
water=[]
for i in range(31):
  for j in range(31):
    w=100*A*i+100*B*j
    if w<F and w!=0:
      water.append(w)
sugar=[]
for i in range(F//C+1):
  for j in range(F//D+1):
    w=C*i+D*j
    if w<F:
      sugar.append(w)
ans1=0
ans2=0
for i in range(len(water)):
  for j in range(len(sugar)):
    if water[i]+sugar[j]<=F:
      if sugar[j]/water[i]<=E/100:
        if noudo<sugar[j]/water[i]:
          ans1=sugar[j]+water[i]
          ans2=sugar[j]
          noudo=sugar[j]/water[i]

print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
from math import gcd
a,b,c,d,e,f=map(int,input().split())
g=gcd(a,b)
a=a//g
b=b//g
G=gcd(c,d)
c=c//G
d=d//G
axby=[0]*1000
czdw=[0]*1000
for x in range(100):
    for y in range(100):
        if a*x+b*y<(a-1)*(b-1):
            axby[a*x+b*y]=1
for z in range(100):
    for w in range(100):
        if c*z+d*w<(c-1)*(d-1):
            czdw[c*z+d*w]=1
A=[]
C=[]
for i in range(1000):
    if axby[i]==1:
        A.append(i)
for i in range(1000):
    if czdw[i]==1:
        C.append(i)
i=(a-1)*(b-1)
while i<=(f//(100*g))+5:
    A.append(i)
    i+=1
j=(c-1)*(d-1)
while j<=(f//G)+5:
    C.append(j)
    j+=1
n=len(A)
m=len(C)
dis=0
ans=[0,0]
for i in range(n):
    for j in range(m):
        if 100*g*A[i]+G*C[j]<=f and G*C[j]<=e*g*A[i] and not(A[i]==C[j]==0):
            if dis<(100*G*C[j])/(100*g*A[i]+G*C[j]):
                dis=(100*G*C[j])/(100*g*A[i]+G*C[j])
                ans[0],ans[1]=A[i],C[j]
print(100*g*ans[0]+G*ans[1],G*ans[1])

Submission status: Wrong Answer

Solution code:
from math import gcd
a,b,c,d,e,f=map(int,input().split())
g=gcd(a,b)
a=a//g
b=b//g
G=gcd(c,d)
c=c//G
d=d//G
axby=[0]*1000
czdw=[0]*1000
for x in range(100):
    for y in range(100):
        if a*x+b*y<(a-1)*(b-1):
            axby[a*x+b*y]=1
for z in range(100):
    for w in range(100):
        if c*z+d*w<(c-1)*(d-1):
            czdw[c*z+d*w]=1
A=[]
C=[]
for i in range(1000):
    if axby[i]==1:
        A.append(i)
for i in range(1000):
    if czdw[i]==1:
        C.append(i)
i=(a-1)*(b-1)
while i<=(f//(100*g))+1:
    A.append(i)
    i+=1
j=(c-1)*(d-1)
while j<=(f//G)+1:
    C.append(j)
    j+=1
n=len(A)
m=len(C)
dis=0
ans=[0,0]
for i in range(n):
    for j in range(m):
        if 100*g*A[i]+G*C[j]<=f and G*C[j]<=e*g*A[i] and A[i]!=0 and C[i]!=0:
            if dis<(100*G*C[j])/(100*g*A[i]+G*C[j]):
                dis=(100*G*C[j])/(100*g*A[i]+G*C[j])
                ans[0],ans[1]=A[i],C[j]
print(100*g*ans[0]+G*ans[1],G*ans[1])

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
sugar = [0] * (f + 5)
for i in range(f + 1):
    if i * c > f:
        break
    for j in range(f + 1):
        if i * c + j * d > f:
            break
        sugar[i * c + j * d] = 1
water = [0] * (f // 100 + 5)
for i in range(f // 100 + 1):
    if i * a > f // 100:
        break
    for j in range(f // 100 + 1):
        if i * a + j * b > f // 100:
            break
        water[i * a + j * b] = 1
m = 0
ans1, ans2 = 0, 0
for i in range(1, f // 100 + 1):
    if water[i] == 0:
        continue
    t = 0
    for j in range(i * e, 0, -1):
        if sugar[j] == 1:
            if 100 * i + j <= f and m <= 100 * j / (i + j):
                ans1, ans2 = 100 * i + j, j
                m = 100 * j / (i + j)
                t = 1
        if t == 1:
            break
print(ans1, ans2)

Submission status: Wrong Answer

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

def reduce(x): #約分
  #print(x)
  d = math.gcd(x[0], x[1])
  return (x[0] // d, x[1] // d)

def is_valid(s, w): #砂糖s、水100w
  return s <= w * E and s + 100*w <= F

ratios = set()

Waters = [] 
for a in range(0, w_max+1, A):
  for b in range(0, w_max+1, B):
    if a == 0 and b == 0 or a + b > F:
      continue
    Waters.append(a+b)
Waters.sort()

s_max = 0
for x in Waters:
  s_max = max(s_max, min(x*E,F-100*x))

Sugars = [] 
for c in range(0, s_max+1, C):
  for d in range(0, s_max+1, D):
    Sugars.append(c+d)
Sugars.sort()

i = 0
ascend = True
for w in Waters:
  while i >= 0 and not is_valid(Sugars[i], w):
    i -= 1
  while 0 <= i < len(Sugars) and is_valid(Sugars[i], w):
    i += 1
  i -= 1
  if i >= 0:
    ratios.add(reduce((Sugars[i], w)))

ans = max(ratios, key = lambda x: float(x[0]/x[1]))
print(ans[1]*100 + ans[0], ans[0])

Submission status: Wrong Answer

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

best_dense = -float("inf")
ans_sum = 0
ans_s_sum = 0


for a in range(31):
    if 100 * A * a <= F:
        for b in range(31):
            if 100 * A * a + 100 * B * b <= F:
                sum = 100 * A * a + 100 * B * b
                w_sum = 100 * A * a + 100 * B * b
                s_max = int(E * w_sum / 100)
                for c in range(s_max + 1):
                    if sum + C * c <= F and C * c <= s_max:
                        for d in range(s_max + 1):
                            if sum + C * c + D * d <= F and C * c + D * d <= s_max:
                                sum = 100 * A * a + 100 * B * b + C * c + D * d
                                s_sum = C * c + D * d
                                if sum != 0:
                                    dense = s_sum / (w_sum + s_sum)
                                    if dense > best_dense:
                                        best_dense = dense
                                        ans_sum = sum
                                        ans_s_sum = s_sum
print(ans_sum, ans_s_sum)

Submission status: Wrong Answer

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

best_dense = -float("inf")

for a in range(31):
    if 100 * A * a <= F:
        for b in range(31):
            if 100 * A * a + 100 * B * b <= F:
                sum = 100 * A * a + 100 * B * b
                w_sum = 100 * A * a + 100 * B * b
                s_max = int(E * w_sum / 100)
                for c in range(s_max + 1):
                    if sum + C * c <= F and C * c <= s_max:
                        for d in range(s_max + 1):
                            if sum + C * c + D * d <= F and C * c + D * d <= s_max:
                                sum = 100 * A * a + 100 * B * b + C * c + D * d
                                s_sum = C * c + D * d
                                if sum != 0:
                                    dense = s_sum / (w_sum + s_sum)
                                    if dense > best_dense:
                                        best_dense = dense
                                        ans_sum = sum
                                        ans_s_sum = s_sum
print(ans_sum, ans_s_sum)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_a = int(3000 / (100 * A))
max_b = int(3000 / (100 * B))
max_c = int(3000 / C)
max_d = int(3000 / D)
max_dens = 0
max_sugar = 0
max_sugar_water = 0
for i in range(max_a + 1):
  water_A = 100 * A * i
  if water_A > F:
    break
  for j in range(max_b + 1):
    water = 100 * B * j + water_A
    if water > F:
      break
    max_solvable_sugar = E * water
    for s in range(max_c + 1):
      sugar_C = C * s
      if sugar_C * 100 > max_solvable_sugar:
        break
      for t in range(max_d + 1):
        sugar = D * t + sugar_C
        if sugar * 100 > max_solvable_sugar:
          break
        sugar_water = water + sugar
        if sugar_water > F or sugar_water == 0:
          break
        dens = 100 * sugar / sugar_water
        if dens > max_dens:
          max_dens = dens
          max_sugar = sugar
          max_sugar_water = sugar_water
print("{} {}".format(max_sugar_water, max_sugar))

Submission status: Wrong Answer

Solution code:
from itertools import product
A,B,C,D,E,F=map(int, input().split())
ans = float("inf")
mass = 0
sugar = 0
for s, t in product(range(0, 31), repeat=2):
    water = 100*(A*s+B*t)
    if water > F:
        continue
    up = min(F-water, E*(A*s+B*t))
    for u in range(0, up+1):
        if C*u > up:
            continue
        v = int((up-C*u)/D)
        if v < 0:
            continue
        if u==0 and v==0:
            continue
        cons = water/(C*u+D*v)
        if cons < ans:
            ans = cons
            mass = water + C*u + D*v
            sugar = C*u+D*v
print(mass, sugar)

Submission status: Wrong Answer

Solution code:
from itertools import product
from decimal import Decimal, getcontext
getcontext().prec = 100
A,B,C,D,E,F=map(int, input().split())
ans = float("inf")
mass = 0
sugar = 0
for s, t in product(range(0, 31), repeat=2):
    water = 100*(A*s+B*t)
    if water > F:
        continue
    up = min(F-water, E*(A*s+B*t))
    for u in range(0, up+1):
        if C*u > up:
            continue
        v = int((up-C*u)/D)
        if u==0 and v==0:
            continue
        cons = water/(C*u+D*v)
        if cons < ans:
            ans = cons
            mass = water + C*u + D*v
            sugar = C*u+D*v
print(mass, sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_a = int(3000 / (100 * A))
max_b = int(3000 / (100 * B))
max_c = int(3000 / C)
max_d = int(3000 / D)

max_dens = 0
max_sugar = 0
max_sugar_water = 0
for i in range(max_a + 1):
  water = 100 * A * i
  if water > F:
    break
  for j in range(max_b + 1):
    water += 100 * B * j
    if water > F:
      break
    max_solvable_sugar = E * int(water/100)
    for s in range(max_c + 1):
      sugar = C * s
      if sugar > max_solvable_sugar:
        break
      for t in range(max_d + 1):
        sugar += D * t
        if sugar > max_solvable_sugar:
          continue
        sugar_water = water + sugar
        if sugar_water > F or sugar_water == 0:
          continue
        dens = 100 * sugar / sugar_water
        if dens > max_dens:
          max_dens = dens
          max_sugar = sugar
          max_sugar_water = sugar_water

print("{} {}".format(max_sugar_water, max_sugar))

Submission status: Wrong Answer

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

for i in range(f//(a*100)+1):
  for j in range(f//(b*100)+1):
    if 100*(i*a+j*b)>f:
      continue
    else:
      water = 100*(i*a+j*b) 
      maxsuger = e*(i*a+j*b)
      for k in range(maxsuger//c+1):
        for l in range(maxsuger//d+1):
          su = k*c+l*d
          if su>maxsuger or (water+su)>f:
            continue
          else:
            if (water+su) != 0:
                nowd = (su/(water+su))*100
                if nowd>dins:
                  suger = su
                  ans = (water+su)
                  dins = nowd
print(ans,suger)

Submission status: Wrong Answer

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

wa=[]
su=[]
for i in range(1,31):
  for j in range(0,31):
    x=i-j*a
    if x>=0:
      if x%b==0:
        wa.append(i*100)
        
for p in range(1,3001):
  for q in range(0,3001):
    y=p-q*c
    if y>=0:
      if y%d==0:
        su.append(p)
        
wa1=list(set(wa))
su1=list(set(su))

ans=0
ans1=[]
for r in wa1:
  for t in su1:
    if r+t<=f and t/r <= e/100:
      if t/(r+t)>=ans:
        ans=t/(r+t)
        ans1.append([r,t])
        
if len(ans1)==0:
  print(str(0)+' '+str(0))
else:
  W=ans1[-1][0]
  S=ans1[-1][1]
  print(str(W+S)+' '+str(S))

Submission status: Wrong Answer

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

wa=[]
su=[]
for i in range(1,31):
  for j in range(0,31):
    x=i-j*a
    if x>=0:
      if x%b==0:
        wa.append(i*100)
        
for p in range(1,3001):
  for q in range(0,3001):
    y=p-q*c
    if y>=0:
      if y%d==0:
        su.append(p)
        
wa1=list(set(wa))
su1=list(set(su))

ans=0
ans1=[]
for r in wa1:
  for t in su1:
    if r+t<=f and t/r <= e/100:
      if t/(r+t)>=ans:
        ans=t/(r+t)
        ans1.append([r,t])
        
if len(ans1)==0:
  print(0)
else:
  W=ans1[-1][0]
  S=ans1[-1][1]
  print(str(W+S)+' '+str(S))

Submission status: Wrong Answer

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

wa=[]
su=[]
for i in range(1,31):
  for j in range(1,31):
    x=i-j*a
    if x>=0:
      if x%b==0:
        wa.append(i*100)
        
for p in range(1,3001):
  for q in range(1,3001):
    y=p-q*c
    if y>=0:
      if y%d==0:
        su.append(p)
        
wa1=list(set(wa))
su1=list(set(su))

ans=0
ans1=[]
for r in wa1:
  for t in su1:
    if r+t<=f and t/r <= e/100:
      if t/(r+t)>=ans:
        ans=t/(r+t)
        ans1.append([r,t])
        
if len(ans1)==0:
  print(0)
else:
  W=ans1[-1][0]
  S=ans1[-1][1]
  print(str(W+S)+' '+str(S))

Submission status: Wrong Answer

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

wa=[]
su=[]
for i in range(1,31):
  for j in range(1,31):
    x=i-j*a
    if x>=0:
      if x%b==0:
        wa.append(i*100)
        
for p in range(1,3001):
  for q in range(1,31):
    y=p-q*c
    if y>=0:
      if y%d==0:
        su.append(p)
        
wa1=list(set(wa))
su1=list(set(su))

ans=0
ans1=[]
for r in wa1:
  for t in su1:
    if r+t<=f and t/r <= e/100:
      if t/(r+t)>ans:
        ans=t/(r+t)
        ans1.append([r,t])
        
if len(ans1)==0:
  print(0)
else:
  W=ans1[-1][0]
  S=ans1[-1][1]
  print(str(W+S)+' '+str(S))

Submission status: Wrong Answer

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

wa=[]
su=[]
for i in range(1,31):
  for j in range(1,31):
    x=i-j*a
    if x>=0:
      if x%b==0:
        wa.append(i*100)
        
for p in range(1,3001):
  for q in range(1,31):
    y=p-q*c
    if y>=0:
      if y%d==0:
        su.append(p)
        
wa1=list(set(wa))
su1=list(set(su))

ans=0
ans1=[]
for r in wa1:
  for t in su1:
    if r+t<=f and t/r <= e/100:
      if t/(r+t)>ans:
        ans1.append([r,t])
        
if len(ans1)==0:
  print(0)
else:
  W=ans1[-1][0]
  S=ans1[-1][1]
  print(str(W+S)+' '+str(S))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A,B,C,D,E,F = map(int, readline().split())
ans = (100*A,0)
max_con = 0

for a in range(31):
    for b in range(31):
        for c in range(31):
            for d in range(31):
                W = a * 100 * A + b * 100 * B
                S = c*C + d*D
                SW = S + W 
                e = W // 100
                if F < SW or SW == 0:
                    continue
                if e * E < S:
                    continue
                tmp = 100 * S / SW
                if tmp > max_con:
                    max_con = tmp
                    ans = (SW,S)
print(' '.join(str(a) for a in ans))

Submission status: Wrong Answer

Solution code:
from math import gcd

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

N = 0; max_S = 0; max_SW = 0
f = F//100; a = f//A; b = f//B
cn = D // gcd(C, D)

for j in range(b+1): #Bをj杯入れる
    for i in range(a+1): #Aをi杯入れる
        if i==0 and j==0:
            continue
        elif A*i + B*j > f:
            continue
        w = (A*i + B*j) * 100 #水の量
        e = (A*i + B*j) * E #この場合において溶ける砂糖の最大値
        S = min(e, F-w) #ビーカーも考慮した砂糖を入れられる限界
        s = 0
        for ci in range(min(S//C, cn)+1):
            s = max(s, S - (S - C*ci) % D)
        if s/(w+s) > N:
            N = s/(w+s)
            max_SW = s + w
            max_S = s

print(max_SW, max_S)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
s = [0,0,0,0]
con1 = 0
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d
                w2 = (100*a*x + 100*b*y -c*v)//d
                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w2,w3)
                con2 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                if con1 <= con2:
                    con1 = con2
                    s = [x,y,v,w]
                else:
                    continue

ans1 = 100*a*s[0] + 100*b*s[1] + c*s[2] + d*s[3]
ans2 = c*s[2] + d*s[3]
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
s = [0,0,0,0]
con1 = 0
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d
                w2 = (100*a*x + 100*b*y -c*v)//d
                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w2,w3)
                con2 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                if con1 < con2:
                    con1 = con2
                    s = [x,y,v,w]
                else:
                    continue

ans1 = 100*a*s[0] + 100*b*s[1] + c*s[2] + d*s[3]
ans2 = c*s[2] + d*s[3]
print(ans1,ans2)

Submission status: Wrong Answer

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

CCT = {}
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        water = (a*A+b*B)*100
        max_suger = water*E//100
        for c in range(max_suger//C+1):
            for d in range(max_suger//D+1):
                suger = c*C+d*D
                if water + suger > F:
                    continue
                if max_suger < suger:
                    continue
                if water+suger == 0:
                    continue
                CCT[water,suger] = 100*suger/(water+suger)

ans = [0, 0]
max_cct = 0
for (water,suger),cct in CCT.items():
    if cct > max_cct:
        max_cct = cct
        ans = [water+suger, suger]
print(*ans)