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:
import sys
import bisect
from fractions import Fraction

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    A, B, C, D, E, F = in_nn()

    water = set()
    for i in range(31):
        for j in range(31):
            t = i * A * 100 + j * B * 100
            if t <= F:
                water.add(t)
            else:
                break
    water = list(sorted(water))

    sugar = set()
    for i in range(3001):
        for j in range(3001):
            t = i * C + j * D
            if t <= F:
                sugar.add(t)
            else:
                break
    sugar = list(sorted(sugar))

    max_f = 0
    ans = (0, 0)
    for w in water:
        for s in sugar:
            if w + s <= F and s <= (w // 100) * E and w + s != 0:
                if max_f < Fraction(s, w + s):
                    max_f = Fraction(s, w + s)
                    ans = (s + w, s)

    print(ans[0], ans[1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import bisect
from fractions import Fraction

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    A, B, C, D, E, F = in_nn()

    water = set()
    for i in range(31):
        for j in range(31):
            t = i * A * 100 + j * B * 100
            if t <= F:
                water.add(t)
            else:
                break

    sugar = set()
    for i in range(3001):
        for j in range(3001):
            t = i * C + j * D
            if t <= F:
                sugar.add(t)
            else:
                break

    max_f = 0
    ans = (0, 0)
    for w in water:
        for s in sugar:
            if w + s <= F and s <= (w // 100) * E and w + s != 0:
                if max_f < Fraction(s, w + s):
                    max_f = Fraction(s, w + s)
                    ans = (s + w, s)

    print(ans[0], ans[1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
Con = 0
a, b = 0, 0
for i in range(F//100 + 1):
    for j in range(F//100 + 1):
        Water = 100 * A * i + 100 * B * j
        if Water > F:
            break
        for x in range(E * Water // 100 + 1):
            for y in range(E * Water // 100 + 1):
                Sugar = C * x + D * y
                if Water + Sugar > F:
                    break
                if Water * E < Sugar * 100:
                    break
                if Sugar + Water == 0:
                    break
                c = (100 * Sugar) / (Sugar + Water)
                if Con < c:
                    Con = c
                    a = Water
                    b = Sugar
print(a + b, b)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
inf=float("inf")
a*=100
b*=100
lst=[[inf,0] for _ in range(f//100)]
for i in range(f//b+1):
    for j in range(f//a+1):
        if i==0 and j==0:
            continue
        if (i*b+j*a)<=f:
            lst[(i*b+j*a)//100-1][0]=(i*b+j*a)

sugarlst=[]
C=max(c,d)
D=min(c,d)

for i in range(1500//C+1):
    for j in range((1500-i*C)//D+1):
        sugarlst.append(C*i+D*j)
sugarlst=set(sugarlst)
sugarlst=sorted(sugarlst)

for i in range(f//100):
    if lst[i][0]==inf:
        continue
    for j in sugarlst:
        weight=lst[i][0]+j
        if weight>f or (lst[i][0]//100)*e<j :
            break
        lst[i][1]=j

noudomax=0
for i in lst:
    noudo=i[1]/(i[0]+i[1])
    if noudo>=noudomax:
        ans=i
        noudomax=noudo
print(ans[0]+ans[1],ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
inf=float("inf")
a*=100
b*=100
lst=[[inf,0] for _ in range(f//100)]
water=a
while water<=f:
    if lst[(water//100)-1][0]==inf:
        lst[(water//100)-1][0]=water
    water+=a
water=b
while water<=f:
    if lst[(water//100)-1][0]==inf:
        lst[(water//100)-1][0]=water
    water+=b

sugarlst=[]
C=max(c,d)
D=min(c,d)

for i in range(1500//C+1):
    for j in range((1500-i*C)//D+1):
        sugarlst.append(C*i+D*j)
sugarlst=set(sugarlst)
sugarlst=sorted(sugarlst)

for i in range(f//100):
    if lst[i][0]==inf:
        continue
    for j in sugarlst:
        weight=lst[i][0]+j
        if weight>f or (lst[i][0]//100)*e<j :
            break
        lst[i][1]=j

noudomax=0
for i in lst:
    noudo=i[1]/(i[0]+i[1])
    if noudo>=noudomax:
        ans=i
        noudomax=noudo
print(ans[0]+ans[1],ans[1])

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  A,B,C,D,E,F=LI()
  ans_pair=[0,0]
  ans_noudo=0
  for a in range(31):
    for b in range(31):
      for c in range(3001):
        for d in range(3001):

          sato=c*C+d*D
          mizu=100*A*a+100*B*b
          satomizu=sato+mizu
          # if satomizu==2634 and sato==934:
          #   print(satomizu,sato)

          if satomizu==0:
            continue

          if F<satomizu:
            break

          noudo=(100*sato)/(satomizu)
          E_noudo=(100*E)/(100+E)
          if E_noudo<noudo:
            break

          if ans_noudo<noudo:
            ans_noudo=noudo
            ans_pair=[satomizu,sato]
            # print(noudo,satomizu,sato,mizu,a,b,c,d)

  return str(ans_pair[0])+' '+str(ans_pair[1])

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  A,B,C,D,E,F=LI()
  ans_pair=[0,0]
  ans_noudo=0
  for a in range(31):
    for b in range(31):
      for c in range(3001):
        for d in range(3001):

          sato=c*C+d*D
          mizu=100*a+100*b
          satomizu=sato+mizu
          # if satomizu==2634 and sato==934:
          #   print(satomizu,sato)

          if satomizu==0:
            continue

          if F<satomizu:
            break

          noudo=(100*sato)/(satomizu)
          E_noudo=(100*E)/(100+E)
          if E_noudo<noudo:
            break

          if ans_noudo<noudo:
            ans_noudo=noudo
            ans_pair=[satomizu,sato]
            # print(noudo,satomizu,sato,mizu)

  return str(ans_pair[0])+' '+str(ans_pair[1])

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  A,B,C,D,E,F=LI()
  ans_pair=[0,0]
  ans_noudo=0
  for a in range(31):
    for b in range(31):
      for c in range(31):
        for d in range(31):

          sato=c*C+d*D
          mizu=100*a+100*b
          satomizu=sato+mizu
          # if satomizu==2634 and sato==934:
          #   print(satomizu,sato)

          if satomizu==0:
            continue

          if F<satomizu:
            continue

          noudo=(100*sato)/(satomizu)
          if E<noudo:
            continue

          if ans_noudo<noudo:
            ans_noudo=noudo
            ans_pair=[satomizu,sato]
            # print(noudo,satomizu,sato,mizu)

  return str(ans_pair[0])+' '+str(ans_pair[1])

# main()
print(main())

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
a, b, c, d, e, f = map(int, input().split())

lim = (f // c) + 1
ans_n = 0
ans_total = 0
ans_su = 0

for ac in range(31):
    for bc in range(31):

        wt = a * ac * 100 + b * bc * 100
        if wt == 0:
            break

        max_su = wt / 100 * e

        for cc in range(lim):
            for dc in range(lim):

                su = c * cc + d * dc

                if (su > max_su) or (wt + su > f):
                    break

                n = (100 * su) / (wt + su)
                if n > ans_n:
                    ans_n = n
                    ans_total = wt+su
                    ans_su = su

print(ans_total, ans_su)

Submission status: Wrong Answer

Solution code:
from itertools import product

A,B,C,D,E,F = map(int, input().split())
num_a = F // (100 * A)
num_b = F // (100 * B) 
num_c = int((F * E / (E + 100)) // C)
num_d = int((F * E / (E + 100)) // D)

def check_w(w_mizu, w_sato, F):
  return w_mizu + w_sato <= F

def check_tokeru(w_mizu, w_sato, E):
  return 100 * w_sato / (w_mizu + w_sato) <= 100 * E / (100 + E)

def culc_density(w_mizu, w_sato):
  return 100 * w_sato / (w_mizu + w_sato)

max = [0, 0, 0]  # total, sato, density
for _a, _b,  in product(range(num_a + 1), range(num_b + 1)): 
  w_mizu = (A * _a + B * _b) * 100
  if w_mizu == 0 or w_mizu >= F:
    continue
    
  for _c, _d in product(range(num_c + 1), range(num_d + 1)):
    w_sato = (C * _c + D * _d)
    if w_sato == 0 or w_sato >= F or (w_mizu + w_sato) > F:
      continue
    
    density = culc_density(w_mizu, w_sato)
  
    if check_w(w_mizu, w_sato, F) and check_tokeru(w_mizu, w_sato, E):
      if max[2] < density:
        max[0] = w_mizu + w_sato
        max[1] = w_sato
        max[2] = density

if max[0]:
  print(max[0], max[1])
else:
  print(F, 0)

Submission status: Wrong Answer

Solution code:
from itertools import product

A,B,C,D,E,F = map(int, input().split())
num_a = F // (100 * A)
num_b = F // (100 * B) 
num_c = int((F * E / (E + 100)) // C)
num_d = int((F * E / (E + 100)) // D)

def check_w(w_mizu, w_sato, F):
  return w_mizu + w_sato <= F

def check_tokeru(w_mizu, w_sato, E):
  return 100 * w_sato / (w_mizu + w_sato) <= 100 * E / (100 + E)

def culc_density(w_mizu, w_sato):
  return 100 * w_sato / (w_mizu + w_sato)

max = [0, 0, 0]  # total, sato, density
for _a, _b,  in product(range(num_a + 1), range(num_b + 1)): 
  w_mizu = (A * _a + B * _b) * 100
  if w_mizu == 0 or w_mizu >= F:
    continue
    
  for _c, _d in product(range(num_c + 1), range(num_d + 1)):
    w_sato = (C * _c + D * _d)
    if w_sato == 0 or w_sato >= F or (w_mizu + w_sato) > F:
      continue
    
    density = culc_density(w_mizu, w_sato)
  
    if check_w(w_mizu, w_sato, F) and check_tokeru(w_mizu, w_sato, E):
      if max[2] < density:
        max[0] = w_mizu + w_sato
        max[1] = w_sato
        max[2] = density

if max[0]:
  print(max[0], max[1])

Submission status: Wrong Answer

Solution code:
from itertools import product

A,B,C,D,E,F = map(int, input().split())
num_a = F // (100 * A)
num_b = F // (100 * B) 
num_c = int((F * E / (E + 100)) // C)
num_d = int((F * E / (E + 100)) // D)

def check_w(w_mizu, w_sato, F):
  return w_mizu + w_sato <= F

def check_tokeru(w_mizu, w_sato, E):
  return 100 * w_sato / (w_mizu + w_sato) <= 100 * E / (100 + E)

def culc_density(w_mizu, w_sato):
  return 100 * w_sato / (w_mizu + w_sato)

max = [0, 0, 0]  # total, sato, density
for _a, _b, _c, _d in product(range(num_a + 1), range(num_b + 1), range(num_c + 1), range(num_d + 1)):
  w_mizu = (A * _a + B * _b) * 100
  if w_mizu == 0:
    continue
  w_sato = (C * _c + D * _d)
  if w_sato == 0:
    continue
  density = culc_density(w_mizu, w_sato)
  
  if check_w(w_mizu, w_sato, F) and check_tokeru(w_mizu, w_sato, E):
    if max[2] < density:
      max[0] = w_mizu + w_sato
      max[1] = w_sato
      max[2] = density

if max[0]:
  print(max[0], max[1])

Submission status: Wrong Answer

Solution code:
from itertools import product

A,B,C,D,E,F = map(int, input().split())
num_a = F // (100 * A)
num_b = F // (100 * B) 
num_c = int((F * E / (E + 100)) // C)
num_d = int((F * E / (E + 100)) // D)

def check_w(w_mizu, w_sato, F):
  return w_mizu + w_sato <= F

def check_tokeru(w_mizu, w_sato, E):
  return 100 * w_sato / (w_mizu + w_sato) <= 100 * E / (100 + E)

def culc_density(w_mizu, w_sato):
  return 100 * w_sato / (w_mizu + w_sato)

max = [0, 0, 0]  # total, sato, density
for _a, _b, _c, _d in product(range(num_a + 1), range(num_b + 1), range(num_c + 1), range(num_d + 1)):
  w_mizu = (A * _a + B * _b) * 100
  if w_mizu == 0:
    continue
  w_sato = (C * _c + D * _d)
  if w_sato == 0:
    continue
  density = culc_density(w_mizu, w_sato)
  
  if check_w(w_mizu, w_sato, F) and check_tokeru(w_mizu, w_sato, E):
    if max[2] < density:
      max[0] = w_mizu + w_sato
      max[1] = w_sato
      max[2] = density
    
print(max[0], max[1])

Submission status: Wrong Answer

Solution code:
from itertools import product

A,B,C,D,E,F = map(int, input().split())
num_a = F // (100 * A)
num_b = F // (100 * B) 
num_c = int((F * E / (E + 100)) // C)
num_d = int((F * E / (E + 100)) // D)

def check_w(w_mizu, w_sato, F):
  return w_mizu + w_sato <= F

def check_tokeru(w_mizu, w_sato, E):
  return 100 * w_sato / (w_mizu + w_sato) <= 100 * E / (100 + E)

def culc_density(w_mizu, w_sato):
  return 100 * w_sato / (w_mizu + w_sato)

max = [0, 0, 0]  # total, sato, density
for _a, _b, _c, _d in product(range(num_a + 1), range(num_b + 1), range(num_c + 1), range(num_d + 1)):
  w_mizu = (A * _a + B * _b) * 100
  if w_mizu == 0:
    continue
  w_sato = (C * _c + D * _d)
  if w_sato == 0:
    continue
  density = culc_density(w_mizu, w_sato)
  
  if check_w(w_mizu, w_sato, F) and check_tokeru(w_mizu, w_sato, E):
    if max[2] < density:
      max[0] = w_mizu + w_sato
      max[1] = w_sato
      max[2] = density
    
print(max[0], max[1])

Submission status: Wrong Answer

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

water_masses = set()
for i in range(31):
    for j in range(31):
        mass = 100 * A * i + 100 * B * j
        if 0 < mass and mass <= F:
            water_masses.add(mass)

sugar_masses = set()
for i in range(3000 // C + 1):
    for j in range(3000 // D + 1):
        mass = C * i + D * j
        if 0 < mass and mass <= F:
            sugar_masses.add(mass)

res_water = 3000
res_sugar = 0
for m_water in water_masses:
    for m_sugar in sugar_masses:
        if m_water + m_sugar > F:
            continue

        con = m_sugar / (m_water + m_sugar)
        if con <= (E / (100 + E)) and con > res_sugar / (res_water + res_sugar):
            res_water = m_water
            res_sugar = m_sugar


print(res_water + res_sugar, res_sugar)

Submission status: Wrong Answer

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

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

print(*memo[ans.index(max(ans))])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
ans = [-1]*10000
# ans[0] = 0
ans[a*100] = 0
ans[b*100] = 0
q1 = a*100
q2 = b*100
p = 0
fin = [0,0]
for i in range(1,f+1):
    if ans[i] == -1:
        continue
    if (ans[i]+c)/(i-ans[i]) <= e*0.01:
        ans[i+c] = max(ans[i]+c,ans[i+c])
    if (ans[i]+d)/(i-ans[i]) <= e*0.01:
        ans[i+d] = max(ans[i]+d,ans[i+d])
    ans[i+a*100] = max(ans[i+a*100],ans[i])
    ans[i+b*100] = max(ans[i+b*100],ans[i])
    if i != 0:
        if ans[i]/i > p:
            # print(p,i)
            p = ans[i]/i
            fin = [i,ans[i]]
# print(ans[190:210])
print(*fin)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from itertools import product

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

a_max = F // (A * 100)
b_max = F // (B * 100)

waters = set()

for a, b in product(range(0, a_max + 1), range(0, b_max + 1)):
    w = (a * A + b * B) * 100
    if w > F:
        continue

    waters.add(w)

waters = sorted(waters)[1:]
sugars = []

for w in sorted(waters):
    f1 = F - w
    f2 = w // 100 * E
    c_max = min(f1 // C, f2 // C)
    d_max = min(f1 // D, f2 // D)

    max_sugar = 0

    for c, d in product(range(0, c_max + 1), range(0, d_max + 1)):
        s = C * c + D * d
        if s > f1 or s > f2:
            continue
        max_sugar = max(max_sugar, s)

    sugars.append(max_sugar)

dense = [Fraction(s, s + w) for w, s in zip(waters, sugars)]

max_dense = 0
index = -1
for i, d in enumerate(dense):
    if d > max_dense:
        max_dense = d
        index = i

if index == -1:
    print(0, 0)
else:
    print(waters[index] + sugars[index], sugars[index])

Submission status: Wrong Answer

Solution code:
from itertools import product

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

a_max = F // (A * 100)
b_max = F // (B * 100)

max_dense = 0
water = 0
sugar = 0

for a, b in product(range(0, a_max + 1), range(0, b_max + 1)):
    w = (a * A + b * B) * 100
    if w > F:
        continue

    c_max = (a * A + b * B) * E // C
    d_max = (a * A + b * B) * E // D

    for c, d in product(range(0, c_max + 1), range(0, d_max + 1)):
        if w + c * C + d * D > F:
            continue
        if c == 0 and d == 0:
            continue

        dense = 100 * (c * C + d * D) / w + c * C + d * D
        if dense > max_dense:
            max_dense = dense
            water = w
            sugar = c * C + d * D

print(water + sugar, sugar)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

A,B,C,D,E,F = I()
lim1 = F//(100*A)
lim2 = F//(100*B)
ans = 0
ansnum = 0
for i in range(lim1+1):
    for j in range(lim2+1):
        w = 100*i*A+100*j*B
        if i == j == 0:
            continue
        if w > F:
            continue
        r = F-w
        num = 0
        lim3 = min(r,(i*A+j*B)*E)//C
        for k in range(1,lim3+1):
            num = max(num,k*C+((min(r,(i*A+j*B)*E)-k*C)//D)*D)
        if 100*num/(w+num) > ansnum:
            ans = [w+num,num]
            ansnum = 100*num/(w+num)
if ans == 0:
    print(A*100,0)
else:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

A,B,C,D,E,F = I()
lim1 = F//(100*A)
lim2 = F//(100*B)
f = F-C
ans = 0
ansnum = 0
for i in range(lim1+1):
    for j in range(lim2+1):
        w = 100*i*A+100*j*B
        if i == j == 0:
            continue
        if w > f:
            continue
        r = F-w
        num = 0
        lim3 = min(r,(i*A+j*B)*E)//C
        for k in range(1,lim3+1):
            num = max(num,k*C+((min(r,(i*A+j*B)*E)-k*C)//D)*D)
        if 100*num/(w+num) > ansnum:
            ans = [w+num,num]
            ansnum = 100*num/(w+num)
if ans == 0:
    print(A*100,0)
else:
    print(*ans)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
W = set(); S = set()
sa = 0; wsa = a * 100
for i in range(0, f + a * 100, a * 100):
    for j in range(0, f + b * 100, b * 100):
        w = i + j
        if w <= f:
            W.add(w)
        else:
            break
for i in range(c, f // 2 + c, c):
    for j in range(0, f // 2 + d, d):
        s = i + j
        if s <= f // 2:
            S.add(s)
        else:
            break
for i in W:
    for j in S:
        if e / (100 + e) >= j / (i + j) > sa / wsa and i + j <= f:
            sa, wsa = j, i + j
print(wsa, sa)

Submission status: Wrong Answer

Solution code:
# Atcoder Review Problems
# sugar Water
A, B, C, D, E, F = map(int, input().split())
dp = [[0 for i in range(3001)] for j in range(3001)]
dp[0][0] = 1
# dp[S][W]= sugar S(g), water W(g) とすることができるか. S+W<=F & 100S<= EW が必要条件
for i in range(3001):
    for j in range(F-i+1):
        if 100*i <= E*j:
            # 必要条件
            if j >= 100*A:
                dp[i][j] |= dp[i][j-100*A]
            if j >= 100*B:
                dp[i][j] |= dp[i][j-100*B]
            if i >= C:
                dp[i][j] |= dp[i-C][j]
            if i >= D:
                dp[i][j] |= dp[i-D][j]
D = []
for i in range(3001):
    for j in range(F-i+1):
        if i+j != 0 and dp[i][j]:
            D.append((i, j, 100*i/(i+j)))
        else:
            D.append((i, j, 0))
D.sort(key=lambda x: x[-1])
a, b, c = D[-1]

print(a+b, a)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
W = set()
S = set()
sa = 1; wsa = 100
for i in range(1,31):
    for j in range(0,31):
        w = i * a + j * b
        if w <= 30:
            W.add(w)
        else:
            break
for i in range(1,1501):
    for j in range(0,1501):
        s = i * c + j * d
        if s <= 1500:
            S.add(s)
        else:
            break
for i in W:
    for j in S:
        if e / (100 + e) >= j / (i * 100 + j) > sa / wsa and i * 100 + j <= f:
            sa, wsa = j, i * 100 + j
print(wsa, sa)

Submission status: Wrong Answer

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

density = 0
s_water = 0
sugar = 0
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 == 0:
                    continue
                if w + s > F:
                    continue
                if w/100 * E >= s:
                    tmp = 100*s / (w + s)
                    if tmp > density:
                        density = tmp
                        s_water = w + s
                        sugar = s
print(s_water, sugar)

Submission status: Wrong Answer

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

a *= 100
b *= 100
DP = [[0, 0] for _ in range(f + 3000)]
DP[a][0] = a
DP[b][0] = b

for i in range(f + 1):
    if DP[i][0] == 0: continue
    for j in c, d:
        if i + j <= f:
            if 100 * (DP[i][1] + j) / (i + j) <= 100 * e / (100 + e):
                if 100 * (DP[i][1] + j) / (i + j) >= 100 * (DP[i + j][1]) / (i + j):
                    DP[i + j] = [i + j, DP[i][1] + j]

ans, water = 0, [a, 0]
for x, y in DP:
    if x == 0: continue
    if 100 * y / x > ans:
        ans = 100 * y / x
        water = [x, y]
print(*water)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=list(map(int,input().split()))
max=0
satou=0
water=0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                a=100*A*i+100*B*j
                s=C*k +D*l
                if a==0:break
                if a+s<=F and (a/100)*E>=s :
                    if max<100*s/(a+s):
                        max=100*s/(a+s)
                        water=a+s
                        satou=s
if satou>0:
    print(water,satou)
else:
    print(100*B,0)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=list(map(int,input().split()))
max=0
satou=0
water=0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                a=100*A*i+100*B*j
                s=C*k +D*l
                if a==0:break
                if a+s<=F and (a/100)*E>=s :
                    if max<100*s/(a+s):
                        max=100*s/(a+s)
                        water=a+s
                        satou=s

print(water,satou)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=list(map(int,input().split()))
max=0
satou=0
water=0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                a=100*A*i+100*B*j
                s=C*k +D*l
                if a==0:break
                if a+s<=F and (a/100)*E>=s :
                    if max<s/(a+s):
                        max=s/(a+s)
                        water=a+s
                        satou=s

print(water,satou)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=list(map(int,input().split()))
max=0
satou=0
water=0
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                a=100*A*i+100*B*j
                s=C*k +D*l
                if a+s<=F and (a/100)*E>=s and a!=0:
                    if max<s/(a+s):
                        max=s/(a+s)
                        water=a+s
                        satou=s

print(water,satou)

Submission status: Wrong Answer

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

dp=[[False]*(f+2) for i in range(f+2)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 100*sugar/(water+sugar)

dp[0][0]=True

for j in range(f+1):
    i=0
    if dp[i][j] and j<=f:
        if 0<i+j+100*a<=f:
            dp[i][j+100*a]=True
        if 0<i+j+100*b<=f:
            dp[i][j+100*b]=True

for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and i+j<=f:
            if 0<i+c+j<=f:
                dp[i+c][j]=True
            if 0<i+d+j<=f:
                dp[i+d][j]=True

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and i*100<=e*j and 0<j+i<=f and tmp<conc(j,i):
            tmp=conc(j,i)
            tmpi=i
            tmpj=j
        if i*100==e*j:
            break

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

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

dp=[[False]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 1000000000000*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=True

for j in range(f+1):
    i=0
    if dp[i][j] and j<=f:
        if 0<i+j+100*a<=f:
            dp[i][j+100*a]=True
        if 0<i+j+100*b<=f:
            dp[i][j+100*b]=True

for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and i+j<=f:
            if 0<i+c+j<=f:
                dp[i+c][j]=True
            if 0<i+d+j<=f:
                dp[i+d][j]=True

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and tmp<conc(j,i)<=limit and 0<j+i<=f:
            tmp=conc(j,i)
            tmpi=i
            tmpj=j
        if tmp==limit:
            break
        

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

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

dp=[[False]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 100*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=True

for j in range(f+1):
    i=0
    if dp[i][j] and j<f+1:
        if 0<=i+j+100*a<f+1:
            dp[i][j+100*a]=True
        if 0<=i+j+100*b<f+1:
            dp[i][j+100*b]=True

for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and i+j<f+1:
            if 0<=i+c+j<f+1:
                dp[i+c][j]=True
            if 0<=i+d+j<f+1:
                dp[i+d][j]=True

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and tmp<conc(j,i)<=limit and 0<j+i<=f:
            tmp=conc(j,i)
            tmpi=i
            tmpj=j
        if tmp==limit:
            break
        

print(tmpi+tmpj, tmpi)