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())
con = 0
water = 0
sugar = 0
for a in range(int(F / 100 / A) + 1):
    for b in range(int((F - a * 100 * A)/ 100 / B) + 1):
        if not a == b == 0:
            for c in range(int((a*A+b*B)*E/C)+1):
                for d in range(int(((a*A+b*B)*E-c*C)/D)+1):
                    if 100*(A*a+B*b)+C*c+D*d <= F:
                        if con < 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D)):
                            con = 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D))
                            sugar = c*C+d*D
                            water = 100*a*A+100*b*B+c*C+d*D
print(water, sugar)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=[100,0]
for i in range(31):
  for j in range(31):
    if i==0 and j==0:
      break
    l1=f-(100*a*i+100*b*j)
    l2=(a*i+b*j)*e
    l=min(l1,l2)
    cc,dc=0,0
    for k in range(l//c+1):
      tc=k
      td=(l-c*tc)//d
      if l-(c*tc+d*td)<l-(c*cc+d*dc):
        cc,dc=tc,td
    wa=100*a*i+100*b*j
    sa=c*cc+d*dc
    tmp=[wa+sa,sa]
    if wa+sa>f or sa>e*(a*i+b*j):
      break
    if tmp[1]/tmp[0]>ans[1]/ans[0]:
      ans=tmp
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



def main():
  ## input
  A,B,C,D,E,F = map(int, input().split())

  # water list
  dp = [0 for i in range(F+1)]
  dp[100*A]=1
  if 100*B<=F: dp[100*B]=1
  Wn = set([100*A,100*B])
  for i in range(A,F+1):
    if dp[i]>0:
      Wn.add(i)
      if i+100*A<=F: dp[i+100*A]=1
      if i+100*B<=F: dp[i+100*B]=1

  # sugar list
  dp = [0 for i in range(F+1)]
  dp[C],dp[D]=[1,1]
  Sn = set([C,D])
  for i in range(C,F+1):
    if dp[i]>0:
      Sn.add(i)
      if i+C<=F: dp[i+C]=1
      if i+D<=F: dp[i+D]=1

  # solve
  ret = [0.0, A, 0]
  for w in Wn:
    for s in Sn:
      if w+s>F or 100*s>E*w:
        continue
      elif 100*s/(w+s) > ret[0]:
        ret = [100*s/(w+s),w+s,s]
  return [ret[1],ret[2]]



if __name__ == "__main__":
  w,s = main()
  print(w,s)

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



def main():
  ## input
  A,B,C,D,E,F = map(int, input().split())

  # water list
  dp = [0 for i in range(F+1)]
  dp[100*A]=1
  if 100*B<=F: dp[100*B]=1
  Wn = set([100*A,100*B])
  for i in range(A,F+1):
    if dp[i]>0:
      Wn.add(i)
      if i+100*A<=F: dp[i+100*A]=1
      if i+100*B<=F: dp[i+100*B]=1

  # sugar list
  dp = [0 for i in range(F+1)]
  dp[C],dp[D]=[1,1]
  Sn = set([C,D])
  for i in range(C,F+1):
    if dp[i]>0:
      Sn.add(i)
      if i+C<=F: dp[i+C]=1
      if i+D<=F: dp[i+D]=1

  # solve
  ret = [0.0, 0, 0]
  for w in Wn:
    for s in Sn:
      if w+s>F or 100*s>E*w:
        continue
      elif 100*s/(w+s) > ret[0]:
        ret = [100*s/(w+s),w+s,s]
  return [ret[1],ret[2]]

if __name__ == "__main__":
  w,s = main()
  print(w,s)

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



def main():
  ## input
  A,B,C,D,E,F = map(int, input().split())
  # make water list
  Wn = [0 for i in range(F+1)]
  Wn[100*A] = 100*A
  if 100*B <= F:
    Wn[100*B] = 100*B
  for i in range(F+1):
    if Wn[i]>0:
      if i+100*A <= F:
        Wn[i+100*A] = i+100*A
      if i+100*B <= F:
        Wn[i+100*B] = i+100*B

  # make sugar list
  Sn = [0 for i in range(F+1)]
  Sn[C] = C
  Sn[D] = D
  for i in range(F+1):
    if Sn[i]>0:
      if i+C <= F:
        Sn[i+C] = i+C
      if i+D <= F:
        Sn[i+D] = i+D

  # solve
  ret = [0,0,0]
  for w in Wn:
    if w == 0:
      continue
    for s in Sn:
      if s == 0:
        continue
      if w+s<=F and 100*s<=E*w and ret[0]<100*s/w:
        ret = [100*s/w,w,s]
  return ret[1]+ret[2],ret[2]


if __name__ == "__main__":
  ws,s = main()
  print(ws,s)

Submission status: Wrong Answer

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math


def noudo(w,s,E,F):
  if w+s > F:
    return 0
  if 100*s/w > E*1.0:
    return 0
  else:
    return 100*s/w


def main():
  ## input
  A,B,C,D,E,F = map(int, input().split())
  # make water list
  Wn = [0 for i in range(F+1)]
  Wn[100*A] = 100*A
  if 100*B <= F:
    Wn[100*B] = 100*B
  for i in range(F+1):
    if Wn[i]>0:
      if i+100*A <= F:
        Wn[i+100*A] = i+100*A
      if i+100*B <= F:
        Wn[i+100*B] = i+100*B

  # make sugar list
  Sn = [0 for i in range(F+1)]
  Sn[C] = C
  Sn[D] = D
  for i in range(F+1):
    if Sn[i]>0:
      if i+C <= F:
        Sn[i+C] = i+C
      if i+D <= F:
        Sn[i+D] = i+D

  # solve
  ret = [0,0,0]
  for w in Wn:
    if w == 0:
      continue
    for s in Sn:
      if s == 0:
        continue
      no = noudo(w,s,E,F)
      if ret[0] < no:
        ret = [no,w,s]
  return ret[1]+ret[2],ret[2]


if __name__ == "__main__":
  ws,s = main()
  print(ws,s)

Submission status: Wrong Answer

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

W = []
for i in range(2 + F // (100 * A)):
    for j in range(2 + (F - 100 * i * A) // (100 * B)):
        W.append(100 * A * i + 100 * B * j)

S = []
for i in range(2 + F // C):
    for j in range(2 + (F - C * i) // D):
        S.append(C * i + D * j)

ma = 0
cand = (0, 0)
for w in W:
    for s in S:
        if w + s > F or E * (w // 100) < s or w + s == 0:
            continue
        t = 100 * s / (w + s)
        if ma < t:
            ma = t
            cand = (w + s, s)

print(*cand)

Submission status: Wrong Answer

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

W = []
for i in range(1 + F // (100 * A)):
    for j in range(1 + F // (100 * B)):
        W.append(100 * A * i + 100 * B * j)

S = []
for i in range(1 + F // C):
    for j in range(1 + F // D):
        S.append(C * i + D * j)

ma = 0
cand = (0, 0)
for w in W:
    for s in S:
        if w + s > F or E * (w // 100) < s or w + s == 0:
            continue
        t = 100 * s / (w + s)
        if ma < t:
            ma = t
            cand = (w + s, s)

print(*cand)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
x, y = [], []  # xが水の量、yが砂糖の量
ans = [0, 0]
MaxConc = 0
for i in range(int(F / 100 / A) + 1):
	for j in range(int(F / 100 / B) + 1):
		x.append(100 * A * i + 100 * B * j)
for i in range(F // C + 1):
	for i in range(F // D + 1):
		y.append(C * i + D * j)
for i in range(len(x)):
	for j in range(len(y)):
		if x[i] + y[j] != 0 and x[i] + y[j] <= F:
			Conc = 100 * y[j] / (x[i] + y[j])
			if Conc <= 100 * E / (100 + E):
				if Conc >= MaxConc:
					ans[0] = x[i] + y[j]
					ans[1] = y[j]
					MaxConc = Conc
print(ans[0], ans[1])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
x, y = [], []  # xが水の量、yが砂糖の量
ans = [0, 0]
MaxConc = 0
for i in range(int(F / 100 / A) + 1):
	for j in range(int(F / 100 / B) + 1):
		x.append(100 * A * i + 100 * B * j)
for i in range(F // C + 1):
	for i in range(F // D + 1):
		y.append(C * i + D * j)
for i in range(len(x)):
	for j in range(len(y)):
		if x[i] + y[j] == 0 or x[i] + y[j] > F:
			break
		Conc = 100 * y[j] / (x[i] + y[j])
		if Conc <= 100 * E / (100 + E):
			if Conc >= MaxConc:
				ans[0] = x[i] + y[j]
				ans[1] = y[j]
				MaxConc = Conc
print(ans[0], ans[1])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans = [1, 0]
tmp = [0, 0]
for x in range(F // 100 // A):
	for y in range(F // 100 // B):
		for z in range(F // C):
			for w in range(F // D):
				if [x, y, z, w] == [0, 0, 0, 0]:
					break
				tmp[0] = 100 * A * x + 100 * B * y + C * z + D * w
				if tmp[0] <= F:
					tmp[1] = 100 * C * z + 100 * D * w
					if tmp[1] / tmp[0] <= 100 * E / (100 + E):
						if ans[1] / ans[0] < tmp[1] / tmp[0]:
							ans[0], ans[1] = tmp[0], tmp[1]
				else:
					break
print(ans[0], ans[1] // 100)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

"""解説
https://www.youtube.com/watch?v=nCHz87GMdpo



"""

def solve2():
    """ 全探索O(F**2) """
    A, B, C, D, E, F = list(map(int, input().split()))

    # 水をx, 砂糖をyとする
    sugars = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            y = i*C + j*D
            if y <= F:
                # 作れる砂糖の量y[g]をメモする
                sugars.append(y)

    water = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            x = 100*A*i + 100*B*j
            if x <= F:
                # 作れる水の量x[g]をメモする
                water.append(x)
    
    sugars.sort()
    water.sort()

    # 濃度
    concent = 0
    for x in water:
        for y in sugars:
            if x+y > F:
                break
            if x+y > 0 and y/(x+y) <= E/(100+E):
                if y/(x+y) >= concent:
                    concent = y/(x+y)
                    ans = "{} {}".format(x+y, y)
    print(ans)


def solve():
    """ WA """
    A, B, C, D, E, F = list(map(int, input().split()))

    # dp[i] := 砂糖水i[g]のときにつくれる最大の砂糖の量
    # 貰うDP
    dp= [0]*(F+1)

    for i in range(0, F+1):
        if i-100*A >= 0:
            dp[i] = max(dp[i], dp[i-100*A])
        if i-100*B >= 0:
            dp[i] = max(dp[i], dp[i-100*B])
        if (i-C >= 0) and ((dp[i-C]+C)/i <= E/(100+E)):
            dp[i] = max(dp[i], dp[i-C]+C)
        if (i-D >= 0) and ((dp[i-D]+D)/i <= E/(100+E)):
            dp[i] = max(dp[i], dp[i-D]+D)
    
    # 各砂糖水に対して濃度を計算し、最大の濃度のときの砂糖水と砂糖の量が答え
    max_noudo = 0
    for i in range(1, F+1):
        now_noudo = dp[i]/i
        if now_noudo >= max_noudo:
            max_noudo = now_noudo
            ans = "{} {}".format(i, dp[i])

    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

"""解説
https://www.youtube.com/watch?v=nCHz87GMdpo



"""

def solve2():
    """ 全探索O(F**2) """
    A, B, C, D, E, F = list(map(int, input().split()))

    # 水をx, 砂糖をyとする
    sugars = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            y = i*C + j*D
            if y <= F:
                # 作れる砂糖の量y[g]をメモする
                sugars.append(y)

    water = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            x = 100*A*i + 100*B*j
            if x <= F:
                # 作れる水の量x[g]をメモする
                water.append(x)
    
    sugars.sort()
    water.sort()

    # 濃度
    concent = 0
    for x in water:
        for y in sugars:
            if x+y > F:
                break
            if x+y > 0 and y/(x+y) <= E/(100+E):
                if y/(x+y) >= concent:
                    concent = y/(x+y)
                    ans = "{} {}".format(x+y, y)
    print(ans)


def solve():
    """ WA """
    A, B, C, D, E, F = list(map(int, input().split()))

    # dp[i] := 砂糖水i[g]のときにつくれる最大の砂糖の量
    # 貰うDP
    dp= [0]*(F+1)

    for i in range(0, F+1):
        if i-100*A >= 0:
            dp[i] = max(dp[i], dp[i-100*A])
        if i-100*B >= 0:
            dp[i] = max(dp[i], dp[i-100*B])
        if (i-C >= 0) and ((dp[i-C]+C)/(i+C) <= E/(100+E)):
            dp[i] = max(dp[i], dp[i-C]+C)
        if (i-D >= 0) and ((dp[i-D]+D)/(i+D) <= E/(100+E)):
            dp[i] = max(dp[i], dp[i-D]+D)
    
    # 各砂糖水に対して濃度を計算し、最大の濃度のときの砂糖水と砂糖の量が答え
    max_noudo = 0
    for i in range(1, F+1):
        now_noudo = dp[i]/i
        if now_noudo >= max_noudo:
            max_noudo = now_noudo
            ans = "{} {}".format(i, dp[i])

    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

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

    # dp[i] := 砂糖水i[g]のときに作れる最大の濃度
    # 配るDP
    dp= [0]*(F+1)

    for i in range(1, F+1):
        if i+100*A <= F:
            concent = (dp[i]*i)/(i+100*A)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*A] = max(dp[i+100*A], concent)
        if i+100*B <= F:
            concent = (dp[i]*i)/(i+100*B)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*B] = max(dp[i+100*B], concent)
        if i+C <= F:
            concent = (dp[i]*i+C)/(i+C)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+C] = max(dp[i+C], concent)
        if i+D <= F:
            concent = (dp[i]*i+D)/(i+D)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+D] = max(dp[i+D], concent)
    
    max_concent = max(dp)
    print(dp.index(max_concent), round(dp.index(max_concent)*max_concent))



if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

def noudo(weight,sugar):
    if sugar is None:return -1000000000
    else:return(sugar*100/weight)
    
def noudosafe(w,s):
    if (noudo(w,s)<=noudo(100+E,E)):return s
    else:return None
    
def eraseNone(i):
    if i is None:return 0
    else: return i
    
dp=[None]*(F+1) #dp[x]はｘｇの砂糖水の中に最大限入っている砂糖の量
dp[0]=0
for i in range(1,F+1):#iグラムの砂糖水
    sug1,sug2,sug3,sug4=[None]*4
    if i>=100*A:
        sug1=dp[i-100*A]
        if sug1 is not None:
            sug1=noudosafe(i,sug1)
    if i>=100*B:
        sug2=dp[i-100*B]
        if sug2 is not None:
            sug2=noudosafe(i,sug2)
    if i>=C:
        sug3base=dp[i-C]
        if sug3base is not None:
            sug3=noudosafe(i,sug3base+C)
    if i>=D:
        sug4base=dp[i-D]
        if sug4base is not None:
            sug4=(noudosafe(i,sug4base+D))
            
    sug=(sug1,sug2,sug3,sug4)
    if all([k is None for k in sug]):
        continue
    else:
        dp[i]=max([eraseNone(k) for k in sug])

ansi=0
anssugar=0
maxnoudo=0
for x,s in enumerate(dp):
    if x==0:continue
    if maxnoudo<noudo(x,s):
        maxnoudo=noudo(x,s)
        ansi=x
        anssugar=s
print(ansi,anssugar)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(65536)

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

def memoize(f):
	memo = {}
	def g(*args):
		if args not in memo:
			memo[args] = f(*args)
		return memo[args]
	return g

@memoize
def search(w, s):
	if 100*w+s > f:
		return (-1, w, s)

	if s > e * w:
		return max(search(a+w, s), search(b+w, s))
	else:
		return max(search(w, s+c), search(w, s+d), (100*s/(100*w+s) if w > 0 else 0, w, s))

_,w,s=search(0, 0)
print(100*w+s, s)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(65536)

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

def memoize(f):
	memo = {}
	def g(*args):
		if args not in memo:
			memo[args] = f(*args)
		return memo[args]
	return g

@memoize
def search(w, s):
	if 100*w+s > f:
		return (-1, w, s)

	if s > e * w:
		return max(search(a+w, s), search(b+w, s))
	else:
		return max(search(w, s+c), search(w, s+d), (100*s/(100*w+s) if w > 0 else -1, w, s))

_,w,s=search(0, 0)
print(100*w+s, s)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
l=[]
for i in range(0,(f//(100*a))+1):
  for j in range(0,(f//(100*b))+1):
    if 100*a*i+100*b*j>=f:
      pass
    else:
      l.append(100*a*i+100*b*j)
l1=[]
del l[0]
max1=0
g=0
h=0
for i in l:
  l2=[]
  m=min(f-i,(i//100)*e)
  max2=0#satounoryou
  for j in range(0,(m//c)+1):
    for k in range(0,(m//d)+1):
      if j*c+k*d<=m and j*c+k*d>max2:
        max2=j*c+k*d
  if max1<100*max2/(i+max2):
    g=i
    h=max2
    max1=100*max2/(i+max2)
print(g+h,h)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
l=[]
for i in range(0,(f//(100*a))+1):
  for j in range(0,(f//(100*b))+1):
    if 100*a*i+100*b*j>=f:
      pass
    else:
      l.append(100*a*i+100*b*j)
l1=[]
del l[0]
max1=0
g=0
h=0
for i in l:
  l2=[]
  m=min(f-i,(i//100)*e)
  max2=0
  for j in range(0,m//c+1):
    for k in range(0,m//d+1):
      if j*c+k*d<=m and j*c+k*d>max2:
        max2=j*c+k*d
  if max1<100*max2/(i+max2):
    g=i
    h=max2
    max1=100*max2/(i+max2)
print(g+h,h)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
l=[]
for i in range(0,f//(100*a)+1):
  for j in range(0,f//(100*b)+1):
    if 100*a*i+100*b*j>=f:
      pass
    else:
      l.append(100*a*i+100*b*j)
l1=[]
del l[0]
max1=0
g=0
h=0
for i in l:
  l2=[]
  m=min(f-i,(i//100)*e)
  max2=0
  for j in range(0,m//c+1):
    for k in range(0,m//d+1):
      if j*c+k*d<=m and j*c+k*d>max2:
        max2=j*c+k*d
  if max1<100*max2/(i+max2):
    g=i
    f=max2
    max1=100*max2/(i+max2)
print(i+max2,max2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
l=[]
for i in range(0,f//(100*a)+1):
  for j in range(0,f//(100*b)+1):
    if 100*a*i+100*b*j>=f:
      pass
    else:
      l.append(100*a*i+100*b*j)
l1=[]
del l[0]
max1=0
g=0
h=0
for i in l:
  l2=[]
  m=min(f-i,(i//100)*e)
  max2=0
  for j in range(0,m//c+1):
    for k in range(0,m//d+1):
      if j*c+k*d<=m and j*c+k*d>max2:
        max2=j*c+k*d
  if max1>100*max2/(i+max2):
    g=i
    f=max2
print(i+max2,max2)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
ans = ["0","0"]
M = 0
for a in range(31):
    if F < a*A*100:
        break
    for b in range(31-a):
        if a == 0 and b == 0:
            continue
        W = (a*A+b*B)*100
        if F < W:
            break
        CD_max = min((E * W) // 100,F-W)
        for c in range(CD_max//C+1):
            d = max(0,(CD_max-c*C)//D)
            CD = c*C+d*D
            con = CD/(W+CD)
            if con > M:
                M = con
                ans = [str(W+CD),str(CD)]
print(" ".join(ans))

Submission status: Wrong Answer

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

now = 0
ans_w = 0
ans_s = 0
lst = []
x = 0
f = 0
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        for c in range(F//C+1):
            for d in range(F//D+1):
                w = A * a * 100 + B * b * 100
                s = C * c + D * d
                if s / E > w / 100 or s + w > F:
                    break
                elif w + s != 0:
                    if now < 100*s/(w+s):
                        now = 100*s/(w+s)
                        ans_w = w
                        ans_s = s

print(ans_w + ans_s, ans_s)

Submission status: Wrong Answer

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

for i in range((F // (A*100) + 1)):
    for j in range((F // (B*100) + 1)):
        gram = (i * A + j * B) * 100
        if gram <= F:
            mizu.append(gram)

for i in range(F // C + 1):
    for j in range(F // D + 1):
        gram = i * C + j * D
        if gram <= F:
            sugars.append(gram)

gram = 0
density = 0
sugar = 0

for m in mizu:
    for s in sugars:
        g = m + s
        if g == 0 or m == 0 or s > m:
            continue
        d = (100 * s) / g
        if g <= F and (s / m) * 100 <= E and density < d:
            density = d
            sugar = s
            gram = g

print(gram, sugar)

Submission status: Wrong Answer

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

for i in range((F // (A*100) + 1)):
    for j in range((F // (B*100) + 1)):
        gram = (i * A + j * B) * 100
        if gram <= F:
            mizu.append(gram)

for i in range(F // C + 1):
    for j in range(F // D + 1):
        gram = i * C + j * D
        if gram <= F:
            sugars.append(gram)

gram = 0
density = 0
sugar = 0

for m in mizu:
    for s in sugars:
        g = m + s
        if g == 0 or m == 0 or s > m:
            continue
        d = (100 * s) / g
        if g <= F and d <= E and density < d:
            density = d
            sugar = s
            gram = g

print(gram, sugar)

Submission status: Wrong Answer

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

for i in range((F // 100 + 1)):
    for j in range((F // 100 + 1)):
        gram = (i * A + j * B) * 100
        if gram <= F:
            mizu.append(gram)
            
for i in range(F+1):
    for j in range(F+1):
        gram = i * C + j * D
        if gram <= F:
            sugars.append(gram)

gram = 0
density = 0
sugar = 0

for m in mizu:
    for s in sugars:
        g = m + s
        if g == 0 or m == 0:
            continue
        d = (100 * s) / g
        if g <= F and d <= E and density < d:
            density = d
            sugar = s
            gram = g

print(gram, sugar)

Submission status: Wrong Answer

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

for i in range(F+1):
    for j in range(F+1):
        gram = (i * A + j * B) * 100
        if gram <= F:
            mizu.append(gram)
            
for i in range(F+1):
    for j in range(F+1):
        gram = i * C + j * D
        if gram <= F:
            sugars.append(gram)

gram = 0
density = 0
sugar = 0

for m in mizu:
    for s in sugars:
        g = m + s
        if g == 0:
            continue
        d = (100 * s) / g
        if g <= F and d <= E and density < d:
            density = d
            sugar = s
            gram = g

print(gram, sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
gram = 0
density = 0
mizu = 0
sugar = 0

for i in range(31):
    for j in range(31):
        for k in range(31):
            for t in range(31):
                a = i * A * 100
                b = j * B * 100
                c = k * C
                d = t * D
                gram = (a+b) + (c+d)
                if gram == 0:
                    continue
                now_den = 100*(c+d)/gram
                if now_den > E or gram > F:
                    continue
                if density < now_den:
                    mizu = a + b
                    sugar = c + d
                    density = max(now_den, density)

print(mizu+sugar, sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
sugar_total = [-1, 1]
for a in range(0, F, 100 * A):
    for b in range(0, F - a, 100 * B):
        water = a + b
        if water == 0:
            continue
        for c in range(0, F - water, C):
            for d in range(0, F - water - c, D):
                sugar = c + d
                total = water + sugar
                if sugar > (water // 100) * E:
                    continue
                if sugar / total > sugar_total[0] / sugar_total[1]:
                    sugar_total[0], sugar_total[1] = sugar, total
print(sugar_total[1], sugar_total[0])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
sugar_total = [0, 1]
for a in range(0, F, 100 * A):
    for b in range(0, F - a, 100 * B):
        water = a + b
        if water == 0:
            continue
        for c in range(0, F - water, C):
            for d in range(0, F - water - c, D):
                sugar = c + d
                total = water + sugar
                if sugar > (water // 100) * E:
                    continue
                if sugar / total > sugar_total[0] / sugar_total[1]:
                    sugar_total[0], sugar_total[1] = sugar, total
print(sugar_total[1], sugar_total[0])

Submission status: Wrong Answer

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

water = []
for a in range(F//A+1):
    for b in range(F//B+1):
        if a + b == 0 or a * A + b * B > F:
            continue
        if not((a * A + b * B) in water):
            water.append(a * A + b * B)

suger = []
for c in range(F//C+1):
    for d in range(F//D+1):
        if c * C + d * D > F:
            continue
        if not((c * C + d * D) in suger):
            suger.append(c * C + d * D)

max_dense = 0
log = [water[0],0]
for w in water:
    for s in suger:
        if w + s > F:
            continue
        dense = 100 * s / (w + s)
        if dense > E:
            continue
        if dense > max_dense:
            max_dense = dense
            log = [w+s,s]

print(" ".join(map(str,log)))

Submission status: Wrong Answer

Solution code:
import math
A, B, C, D, E, F = map(int, input().split())
limit_r = 100 * E / (100 + E)
max_r, max_w, max_s = 0, 0, 0
for a in range(math.ceil(F/100/A)+1):
  for b in range(math.ceil(F/100/B)+1):
    w = 100 * A * a + 100 * B * b
    if w == 0:
      continue
    if w > F:
      break
    for c in range(math.ceil((F-w)/C)+1):
      for d in range(math.ceil((F-w)/D)+1):
        s = C * c + D * d
        r = 100 * s / (w + s)
        if s == 0:
          continue
        if w + s > F or r > limit_r:
          break
        if r > max_r:
          max_r, max_w, max_s = r, w, s
print("{0} {1}".format(max_w+max_s, max_s))

Submission status: Wrong Answer

Solution code:
import math
A, B, C, D, E, F = map(int, input().split())
limit_r = 100 * E / (100 + E)
max_r, max_w, max_s = 0, 0, 0
for a in range(math.ceil(F/100/A)+1):
  for b in range(math.ceil(F/100/B)+1):
    w = 100 * A * a + 100 * B * b
    if w == 0:
      continue
    if w > F:
      break
    for c in range(math.ceil(F/C)+1):
      for d in range(math.ceil(F/D)+1):
        s = C * c + D * d
        r = 100 * s / (w + s)
        if s == 0 or w + s > F or r > limit_r:
          break
        if r > max_r:
          max_r, max_w, max_s = r, w, s
print("{0} {1}".format(max_w+max_s, max_s))

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans = [[0, 0]]
for i in range(0, F//100):
    for j in range(0, F//100):
        if 100*A*i + 100*B*j == 0:
            continue
        for k in range(0, F//C+1):
            for l in range(0, F//D+1):
                if 100*A*i + 100*B*j + C*k + D*l > F:
                    break
                if  (C*k + D*l)/(100*A*i + 100*B*j) > E/100:
                    break
                ans.append([(100*A*i + 100*B*j + C*k + D*l), (C*k + D*l)])
ans = sorted(ans, key=lambda x: x[1]/x[0] if x[0] != 0 else 0)
print(ans[-1])

Submission status: Wrong Answer

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

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

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

ans = [F, 0]
maxc = 0
for aq in AQ:
    for sg in SG:
        if aq+sg > F or sg > aq*E/100:
            continue
        if maxc*(aq+sg) < sg:
            ans = [aq, sg]
            maxc = sg/(aq+sg)
print(ans[0]+ans[1], ans[1])

Submission status: Wrong Answer

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

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

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

ans = [0, 0]
maxc = 0
for aq in AQ:
    for sg in SG:
        if aq+sg > F or sg > aq*E/100:
            continue
        if maxc*(aq+sg) < sg:
            ans = [aq, sg]
            maxc = sg/(aq+sg)
if maxc == 0:
    print(0, 0)
else:
    print(ans[0]+ans[1], ans[1])

Submission status: Wrong Answer

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

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

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

ans = [0, 0]
maxc = 0
for aq in AQ:
    for sg in SG:
        if aq+sg > F or sg > aq*E/100:
            continue
        if maxc*(aq+sg) < sg:
            ans = [aq, sg]
            maxc = sg/(aq+sg)
print(ans[0]+ans[1], ans[1])

Submission status: Wrong Answer

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

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

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

ans = [0, 0]
maxc = 0
for aq in AQ:
    for sg in SG:
        if aq == 0:
            continue
        if aq+sg > F or sg/aq > E/100:
            continue
        if maxc < sg/(aq+sg):
            ans = [aq, sg]
            maxc = sg/(aq+sg)
if maxc == 0:
    print(0, 0)
else:
    print(ans[0]+ans[1], ans[1])

Submission status: Wrong Answer

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

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

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

ans = [0, 0]
maxc = 0.0
for aq in AQ:
    for sg in SG:
        if aq == 0:
            continue
        if aq+sg > F or sg/aq > E/100:
            continue
        if maxc < sg/(aq+sg):
            ans = [aq, sg]
            maxc = sg/(aq+sg)
if maxc == 0.0:
    print(0, 0)
else:
    print(ans[0]+ans[1], ans[1])