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())
ans=(0,0,0)
F+=1
E=100*E/(100+E)
for a in range(0,F,A*100):
	for b in range(0,F-a,B*100):
		for c in range(0,F-a-b,C):
			for d in range(0,F-a-b-c,D):
				if c==0 and d==0:continue
				s=a+b+c+d
				e=100*(c+d)/s
				if ans[2]< e <= E:
					ans=(s,c+d,e)
				elif e>E:break
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
ans=(0,0,0)
F+=1
E=100*E/(100+E)
for a in range(0,F,A*100):
	for b in range(0,F-a,B*100):
		for c in range(0,F-a-b,C):
			for d in range(0,F-a-b-c,D):
				if c==0 and d==0:continue
				s=a+b+c+d
				if ans[2]<100*(c+d)/s <= E:
					ans=(s,c+d,100*(c+d)/s)
				else:break

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

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
ans=(0,0,0)
F+=1
E=100*E/(100+E)
for a in range(0,F,A*100):
	for b in range(0,F-a,B*100):
		for c in range(0,F-a-b,C):
			for d in range(0,F-a-b-c,D):
				if c==0 and d==0:continue
				s=a+b+c+d
				if ans[2]<=100*(c+d)/s <= E:
					ans=(s,c+d,100*(c+d)/s)
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    mn = 0
    ret = (100, 0)
    for a in range((F // 100) // A + 1):
        for b in range(((F // 100) - a * A) // B + 1):
            w = a * A + b * B
            if w < 1:
                continue
            for c in range(E * w // C + 1):
                for d in range((E * w - c * C) // D + 1):
                    s = (c * C + d * D)
                    r = s / w
                    if w * 100 + s <= F and r <= E and r > mn:
                        mn = r
                        ret = (w * 100 + s, s)
    print(ret[0], ret[1])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    mn = 0
    ret = (0, 0)
    for a in range((F // 100) // A + 1):
        for b in range(((F // 100) - a * A) // B + 1):
            w = a * A + b * B
            if w < 1:
                continue
            for c in range(E * w // C + 1):
                for d in range((E * w - c * C) // D + 1):
                    s = (c * C + d * D)
                    r = s / w
                    if w * 100 + s <= F and r <= E and r > mn:
                        mn = r
                        ret = (w * 100 + s, s)
    print(ret[0], ret[1])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water = []
sugar = []
for i in range(1+F//A):
    for j in range(1+F//B):
        if i * A + j * B <= F:
            water.append(i * A + j * B)
for i in range(1+F//C):
    for j in range(1+F//D):
        if i * C + j * D <= F:
            sugar.append(i * C + j * D)
max_sugar_percent = 0
max_sugar_water = 0
max_sugar = 0
water.sort()
sugar.sort()
for i in water:
    for j in sugar:
        if i + j > F:
            break
        if j > E * i / 100:
            break
        sugar_percent = i and (100 * j) / (i + j)
        if sugar_percent >= max_sugar_percent:
            sugar_percent = max_sugar_percent
            max_sugar = j
            max_sugar_water = i + j
print(max_sugar_water, max_sugar)

Submission status: Wrong Answer

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

water = []
sugar = []

for i in range(1 + f // a):
    for j in range(1 + f // b):
        if i * a + j * b <= f:
            water.append(i * a + j * b)

for i in range(1 + f // c):
    for j in range(1 + f // d):
        if i * c + j * d <= f:
            sugar.append(i * c + j * d)

max_sugar_percent = 0
max_sugarwater = 0
max_sugar = 0

for w in water:
    for s in sugar:
        if w + s > f:
            continue

        if s > e * w / 100:
            continue

        sugar_percent = w and (100 * s) / (w + s)
        if sugar_percent > max_sugar_percent:
            max_sugar_percent = sugar_percent
            max_sugar = s
            max_sugarwater = w + s

print(max_sugarwater, max_sugar)

Submission status: Wrong Answer

Solution code:
import math
a,b,c,d,e,f=map(int,input().split())
m_suger=f*e/(100+e)
water=set()
w=math.floor(f/100/a)*a
water.add(w)
f_=f//100
while(1):
     w-=a
     if w<0:
          break
     w_=w
     while(w_<=f_):
          water.add(w_)
          w_+=b
water.remove(0)
m_rate=0
m_content=[0,0]
for w in water:
     res=f-w*100
     m_suger=min(w*e,res)
     s=math.floor(m_suger/c)*c
     while(1):
          if s<=m_suger:
               rate=s/(w+s)
               if rate>m_rate:
                    m_rate=rate
                    m_content=[w,s]
          s-=c
          if s<0:
               break
          s_=s
          while(s_<=m_suger):
               rate=s_/(w+s_)
               if rate>m_rate:
                    m_rate=rate
                    m_content=[w,s_]
               s_+=d
print(m_content[0]*100+m_content[1],m_content[1])

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
water = []
suger = []
ans = [0, 0]
ans_max = 0
for i in range(f//100+1):
  for j in range(f//100+1):
    x = 100*(i*a+j*b)
    if x <= f and x > 0 and x not in water:
      water.append(x)
for i in range(f):
  for j in range(f):
    y = c*i + d*j
    if y <= f and y not in suger:
      suger.append(y)

for i in water:
  if i == 0:
      continue
  for j in suger:
    if (i+j <= f) and (i*e >= 100*j):
      percent = (100*j)/(i+j)
      if ans_max < percent:
        ans_max = percent
        ans = [i, j]
print(sum(ans), ans[1])

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
water = []
suger = []
ans = [0, 0]
ans_max = 0
for i in range(f//100+1):
  for j in range(f//100+1):
    x = 100*(i*a+j*b)
    if x <= f and x > 0:
      water.append(x)
for i in range(f):
  for j in range(f):
    y = c*i + d*j
    if y <= f:
      suger.append(y)

for i in set(water):
  if i == 0:
      continue
  for j in set(suger):
    if (i+j <= f) and (i*e >= 100*j):
      percent = (100*j)/(i+j)
      if ans_max < percent:
        ans_max = percent
        ans = [i, j]
print(sum(ans), ans[1])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
ANS = [0, 0]
Den = 0
for i in range(F//(100 * A) + 2):
	for j in range((F - 100 * A * i)//(100 * B) + 2):
		for k in range(((i * A + j * B) * E)//C + 2):
			if (i * A + j * B)*100 + k * C > F:
				break
			elif (i * A + j * B) * E - k * C < 0:
				break
			else:
				l = min((((i * A + j * B) * E) - k * C)//D,(F - ((i * A + j * B) * 100 + k * C))//D)
			try:
				den = (k * C + l * D)/((i * A + j * B) * 100 + k * C + l * D)
			except ZeroDivisionError:
				den = 0
			if den > Den:
				Den = den
				ANS[0] = (i * A + j * B) * 100 + k * C + l * D
				ANS[1] = k * C + l * D
print(ANS[0], ANS[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
ans = [0,0,0]
for i in range(f//(a*100)+1):
  for j in range((f-a*100*i)//(b*100)+1):
    for k in range((f-a*i*100-b*j*100)//c+1):
      for l in range((f-a*i*100-b*j*100-c*k)//d+1):
        w = i*a+j*b
        s = k*c+l*d
        if w == 0:
          continue
        if w*e >= s and ans[0] < s/(w*100+s):
          ans = [s/(w*100+s),w*100+s,s]
print(ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
ans = [0,0,0]
for i in range(f//(a*100)+1):
  for j in range((f-a*100*i)//(b*100)+1):
    for k in range((f-a*i*100-b*j*100)//c+1):
      for l in range((f-a*i*100-b*j*100-c*k)//d+1):
        w = i+j
        s = k+l
        if w == 0:
          continue
        if w*e >= s and ans[0] < s/(w*100+s):
          ans = [s/(w*100+s),w*100+s,s]
print(ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
ans = [0,0,0]
for i in range(f//(a*100)+1):
  for j in range((f-a*100*i)//(b*100)+1):
    for k in range((f-a*i*100-b*j*100)//c+1):
      for l in range((f-a*i*100-b*j*100-c*k)//d+1):
        w = i+j
        s = k+l
        if w == 0:
          continue
        if w*e >= k and ans[0] < s/(w*100+s):
          ans = [s/(w*100+s),w*100+s,s]
print(ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
ans = [0,0,0]
for i in range(f//(a*100)+1):
  for j in range((f-a*100*i)//(b*100)+1):
    for k in range((f-a*i*100-b*j*100)//c+1):
      for l in range((f-a*i*100-b*j*100-c*k)//d+1):
        w = i+j
        s = k+l
        if w == 0:
          continue
        if w*e >= k and ans[0] < s/(w*100+s):
          ans = [s/(w*100+s),w*100,s]
print(ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

ans = [100, 0]
for w in water:
    for s in sugar:
        if w + s <= F and s <= E * w // 100:
            if s / (w + s) > ans[1] / ans[0]:
                ans = [w + s, s]
            
print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

ans = [100, -1]
for w in water:
    for s in sugar:
        if w + s <= F and s / w * 100 <= E:
            if s / (w + s) > ans[1] / ans[0]:
                ans = [w + s, s]
            
print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

ans = [100, 0]
for w in water:
    for s in sugar:
        if w + s <= F and s / w * 100 <= E:
            if s / (w + s) > ans[1] / ans[0]:
                ans = [w + s, s]
            
print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

ans = [100, 0]
for w in water:
    for s in sugar:
        y = 100 * s / (w + s)
        if w + s <= F and s / w * 100 <= E and y > ans[1] / ans[0] * 100:
            ans = [w + s, s]
            
print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

ans = [100, 0]
for w in water:
    for s in sugar:
        y = 100 * s / (w + s)
        if w + s <= F and s / w * 100 <= E and y > ans[1] / ans[0]:
            ans = [w + s, s]
            
print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

ans = [100, 0]
for w in water:
    for s in sugar:
        y = 100 * s / (w + s)
        if w + s <= F and s / w <= E and y > ans[1] / ans[0]:
            ans = [w + s, s]
            
print(*ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

ans = [100, 0]
for w in water:
    for s in sugar:
        y = 100 * s / (w + s)
        if w + s <= F and y <= E and y > ans[1] / ans[0]:
            ans = [w + s, s]
            
print(*ans)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
water=set({})
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        if 100*A*i + 100*B*j <= F:
            water|={100*A*i + 100*B*j}
sugar=set({})
for i in range(F//C+1):
    for j in range(F//D+1):
        if C*i + D*j <= F:
            sugar|={C*i + D*j}
water-=set({0})
max_=0
for w in water:
    for s in sugar:
        if w+s<=F and s*(100+E)<E*(w+s) and max_*(w+s)<=s:
            max_=s/(w+s)
            ans=[w+s,s]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
import math

A,B,C,D,E,F=map(int,input().split())
max_=0
ans=[100*A,0]
for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        for k in range((F-100*A*i-100*B*j)//C+1):
            E=Decimal(E)
            a=E/(100+E)
            bunshi=100*A*i+100*B*j+C*k
            l=min((F-bunshi)//D,math.floor((a*bunshi-C*k)/((1-a)*D)))
            if bunshi+D*l==0 or l<0:
                continue
            if max_<(C*k+D*l)/(bunshi+D*l):
                max_ = (C*k+D*l)/(bunshi+D*l)
                ans = [bunshi+D*l,C*k+D*l]
print(int(ans[0]),int(ans[1]))

Submission status: Wrong Answer

Solution code:
from decimal import Decimal

A,B,C,D,E,F=map(int,input().split())
max_=0
ans=[100*A,0]
for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        for k in range((F-100*A*i-100*B*j)//C+1):
            E=Decimal(E)
            a=E/(100+E)
            bunshi=100*A*i+100*B*j+C*k
            l=min((F-bunshi)//D,(a*bunshi-C*k)/((1-a)*D))
            if bunshi+D*l==0 or l<0:
                continue
            if max_<(C*k+D*l)/(bunshi+D*l):
                max_ = (C*k+D*l)/(bunshi+D*l)
                ans = [bunshi+D*l,C*k+D*l]
print(int(ans[0]),int(ans[1]))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
max_=0
ans=[100*A,0]
for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        for k in range((F-100*A*i-100*B*j)//C+1):
            a=E/(100+E)
            bunshi=100*A*i+100*B*j+C*k
            l=min((F-bunshi)//D,((a*bunshi)-C*k)//((1-a)*D))
            if bunshi+D*l==0 or l<0:
                continue
            if max_<(C*k+D*l)/(bunshi+D*l):
                max_ = (C*k+D*l)/(bunshi+D*l)
                ans = [bunshi+D*l,C*k+D*l]
print(int(ans[0]),int(ans[1]))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
max_=0
ans=[0,0]
ans_=[0,0,0,0]
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range(F//C+1):
            for l in range(F//D+1):
                temp=100*A*i+100*B*j+C*k+D*l
                temp2=C*k+D*l
                if temp==0:
                    pass
                elif temp<=F and max_<temp2/temp<=E/(100+E):
                    max_ = temp2/temp
                    ans = [temp,temp2]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
max_=0
ans=[0,0]
ans_=[0,0,0,0]
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range(F//C+1):
            for l in range(F//D+1):
                if i==j==k==l:
                    pass
                elif 100*A*i+100*B*j+C*k+D*l<=F and max_<100*(C*k+D*l)/(100*A*i+100*B*j+C*k+D*l)<=E:
                    max_ = (k+l)/(100*A*i+100*B*j+C*k+D*l)
                    ans = [100*A*i+100*B*j+C*k+D*l,C*k+D*l]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
max_=0
ans=[0,0]
for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        for k in range((F-100*A*i-100*B*j)//C+1):
            a=E/(100+E)
            bunshi=100*A*i+100*B*j+C*k
            l=min((F-bunshi)//D,((a*bunshi)-C*k)//((1-a)*D))
            if bunshi+D*l==0 or l<0:
                continue
            if max_<(C*k+D*l)/(bunshi+D*l):
                max_ = (C*k+D*l)/(bunshi+D*l)
                ans = [bunshi+D*l,C*k+D*l]
print(int(ans[0]),int(ans[1]))

Submission status: Wrong Answer

Solution code:
## TLE、保存用

from collections import deque

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

operation = [(100*A,0),(100*B,0),(0,C),(0,D)]
concentration = [(0,0,0)] # (water, sugar, concentration)

def bfs():
    dq = deque()
    dq.append((0,0))
    while dq:
        water,sugar = dq.popleft()
        for op_water,op_sugar in operation:
            new_water = water + op_water; new_sugar = sugar + op_sugar
            if new_water+new_sugar <= F and new_water*E >= 100*new_sugar:
                dq.append((new_water,new_sugar))
                concentration.append((new_water,new_sugar,new_sugar/(new_water+new_sugar)))

bfs()
max_concentration = sorted(concentration, key=lambda x:x[2], reverse=True)[0]
ans_weight = int(max_concentration[0]+max_concentration[1])
ans_sugar = int(max_concentration[1])
print(ans_weight, ans_sugar)

Submission status: Wrong Answer

Solution code:
# ABC074C - Sugar Water
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100

# default values
x, y = (min(a, b) * 100 + min(c, d)), min(c, d)
dens = y / x

# full search
for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        water = i * A + j * B
        rest = f - water
        for k in range(rest // c + 1):
            for l in range((rest - c * k) // d + 1):
                if k == 0 and l == 0:
                    continue
                sugar = c * k + d * l
                total = water + sugar

                if sugar / total > e / (e + 100):
                    break
                else:
                    if sugar / total > dens:
                        dens = sugar / total
                        x, y = total, sugar
print(x, y)

Submission status: Wrong Answer

Solution code:
# ABC074C - Sugar Water
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100
lst_w = []
lst_s = []

# water list
for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        lst_w.append(i * A + j * B)
lst_w = sorted(set(lst_w))

# sugar list
f_s = f - min(A, B)
for i in range(f_s // c + 1):
    for j in range((f_s - c * i) // d + 1):
        if i == 0 and j == 0:
            continue
        lst_s.append(c * i + d * j)
lst_s = sorted(set(lst_s))

# check all of the possible combinations
x, y = lst_s[0] + lst_w[0], lst_s[0]
ans = y / x
for i in lst_w:
    for j in lst_s:
        if i + j >= f:  # compare to f (the max weight)
            break
        else:
            if j / (i + j) > e / (e + 100):  # compare to e (the max density)
                break
            else:
                if j / (i + j) > ans:
                    ans = j / (i + j)
                    x, y = i + j, j
print(x, y)

Submission status: Wrong Answer

Solution code:
# ABC074C - Sugar Water
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100
lst_w = []
lst_s = []

# water list
for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        lst_w.append(i * A + j * B)
lst_w = sorted(set(lst_w))

# sugar list
f_s = f - min(A, B)
for i in range(f_s // c + 1):
    for j in range((f_s - c * i) // d + 1):
        if i == 0 and j == 0:
            continue
        lst_s.append(c * i + d * j)
    i += 1
lst_w = sorted(set(lst_w))
lst_s = sorted(set(lst_s))

# check all of the possible combinations
x, y = lst_s[0] + lst_w[0], lst_s[0]
ans = y / x
for i in lst_w:
    for j in lst_s:
        if i + j >= f:
            break
        else:
            if j / (i + j) > e / (e + 100):
                break
            else:
                if j / (i + j) >= ans:
                    ans = j / (i + j)
                    x, y = i + j, j
print(x, y)

Submission status: Wrong Answer

Solution code:
# ABC074C - Sugar Water
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100
lst_w = []
lst_s = []

# water list
for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        lst_w.append(i * A + j * B)
lst_w = sorted(set(lst_w))

# sugar list
f_s = f - min(A, B)
for i in range(f_s // c + 1):
    for j in range((f_s - c * i) // d + 1):
        if i == 0 and j == 0:
            continue
        lst_s.append(c * i + d * j)
    i += 1
lst_w = sorted(set(lst_w))
lst_s = sorted(set(lst_s))

# check all of the possible combinations
x, y = lst_s[0] + lst_w[0], lst_s[0]
ans = y / x
for i in lst_w[1:]:
    for j in lst_s[1:]:
        if i + j >= f:
            break
        else:
            if j / (i + j) > e / (e + 100):
                break
            else:
                if j / (i + j) > ans:
                    ans = j / (i + j)
                    x, y = i + j, j
print(x, y)

Submission status: Wrong Answer

Solution code:
# ABC074C - Sugar Water
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
lst_w = []
lst_s = []

i = 0
while 100 * a * i <= f:
    w_a = 100 * a * i
    for j in range((f - w_a) // (100 * b) + 1):
        lst_w.append(w_a + 100 * b * j)
    i += 1
lst_w = sorted(set(lst_w))

i = 0
f_s = f - min(a, b) * 100
while c * i <= f_s:
    s_c = c * i
    for j in range((f_s - s_c) // d + 1):
        lst_s.append(s_c + d * j)
    i += 1
lst_w = sorted(set(lst_w))
lst_s = sorted(set(lst_s))

ans = lst_s[1] / (lst_s[1] + lst_w[1])
x, y = lst_s[1] + lst_w[1], lst_s[1]
for i in lst_w[2:]:
    for j in lst_s[2:]:
        if i + j >= f:
            break
        else:
            if j / (i + j) > e / (e + 100):
                break
            else:
                if j / (i + j) > ans:
                    ans = j / (i + j)
                    x, y = i + j, j
print(x, y)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
A,B,C,D,E,F = [int(x) for x in input().split()]

x = []
y = []
ans_max = 0
ans = [0,0]

for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*(A*i+B*j)
        if(water<=F and not water in x):
            x.append(water)

ans[0]=x[0]

for i in range(F):
    for j in range(F):
        salt = C*i+D*j
        if(salt<=F and not salt in y):
            y.append(salt)

for i in x:
    for j in y:
        if(i==0):
            continue
        elif(100*j <= i*E and i+j <= F):
            percent = 100*j/(i+j)
            if(ans_max < percent):
                ans_max = percent
                ans = [i,j]

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
A,B,C,D,E,F = [int(x) for x in input().split()]

x = []
y = []
ans_max = 0
ans = [0,0]

for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*(A*i+B*j)
        if(water<=F and not water in x):
            x.append(water)

for i in range(F):
    for j in range(F):
        salt = C*i+D*j
        if(salt<=F and not salt in y):
            y.append(salt)

for i in x:
    for j in y:
        if(i==0):
            continue
        elif(100*j <= i*E and i+j <= F):
            percent = 100*j/(i+j)
            if(ans_max < percent):
                ans_max = percent
                ans = [i,j]

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

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
if f <= a*100 and f <= b*100:
    print(f,0)
else:
    ab = min(a*100,b*100)
    aki = f-ab
    if aki <= c and aki <= d:
        print(ab,0)
    else:
        cd = min(e%c,e%d)
        salt = e-cd
        print(ab+salt,salt)

Submission status: Wrong Answer

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

for a in range(100):
    a *= A
    if a > F:
        break

    for b in range(100):
        b *= B
        water = a+b
        if water == 0 or water > F:
            break
        limit = water/100 * E

        for c in range(100):
            c *= C
            if c > limit or water+c > F:
                break

            for d in range(100):
                d *= D
                sugar = c+d
                if sugar > limit or water+sugar > F:
                    break
                if sugar != 0:
                    tmp = 100*sugar / (water+sugar)
                    if tmp > conc:
                        conc = tmp
                        W = water
                        S = sugar

print(W+S, S)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
W, S = 0, 0
conc = 0
num = E//2

for a in range(num):
    a *= A
    if a > F:
        break

    for b in range(num):
        b *= B
        water = a+b
        if water == 0 or water > F:
            break
        limit = water/100 * E

        for c in range(num):
            c *= C
            if c > limit or water+c > F:
                break

            for d in range(num):
                d *= D
                sugar = c+d
                if sugar > limit or water+sugar > F:
                    break
                if sugar != 0:
                    tmp = 100*sugar / (water+sugar)
                    if tmp > conc:
                        conc = tmp
                        W = water
                        S = sugar

print(W+S, S)

Submission status: Wrong Answer

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

for a in range(30):
    a *= A
    if a > F:
        break
    for b in range(30):
        b *= B
        water = a+b
        if water == 0 or water > F:
            break
        limit = water//100 * E
        for c in range(30):
            c *= C
            if c > limit or water+c > F:
                break
            for d in range(30):
                d *= D
                sugar = c+d
                if sugar > limit or water+sugar > F:
                    break
                if water != 0 and sugar != 0:
                    tmp = 100*sugar // (water+sugar)
                    if tmp > conc:
                        conc = tmp
                        W = water
                        S = sugar

print(W+S, S)

Submission status: Wrong Answer

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

dens=0
max1=0
max2=0
for a in range(30+1):
  for b in range(30+1):
    waterA=100*a*A
    waterAB=waterA+100*b*B
    if  waterA<= F and 0 < waterAB <= F:
      for c in range(100+1):
        for d in range(100+1):
          if waterAB+c*C+d*D <= F and c*C+d*D <= (a*A+b*B)*E:
            if dens < (c*C+d*D)/(waterAB+c*C+d*D):
              dens=(c*C+d*D)/(waterAB+c*C+d*D)
              max1=waterAB+c*C+d*D
              max2=c*C+d*D
              
print(max1,max2)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
con = 0
sugar_water = 0
sugar = 0
for a in range(30):
    for b in range(31):
        if not a == b == 0 and a*A*100 + b*B*100 <= F:
            for c in range(int((F - a*A*100 + b*B*100) / C) + 1):
                for d in range(int((F - a*A*100 + b*B*100 + c*C) / D) + 1):
                    if 100*(A*a+B*b)+C*c+D*d <= F:
                        if (c*C+d*D)/(100*a*A+100*b*B+c*C+d*D) <= E/(100+E):
                            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
                            sugar_water = 100*a*A+100*b*B+c*C+d*D
print(sugar_water, sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
con = 0
sugar_water = 0
sugar = 0
for a in range(30):
    for b in range(31):
        if not a == b == 0 and a*A*100 + b*B*100 <= F:
            for c in range(int((a*A*100 + b*B*100 - F) / C) + 1):
                for d in range(int((a*A*100 + b*B*100 + c*C - F) / D) + 1):
                    if 100*(A*a+B*b)+C*c+D*d <= F:
                        if (c*C+d*D)/(100*a*A+100*b*B+c*C+d*D) <= E/100+E:
                            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
                            sugar_water = 100*a*A+100*b*B+c*C+d*D
print(sugar_water, sugar)