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
readline = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, readline().rstrip().split())
    X = set()
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if 100 * a * A + 100 * b * B <= F:
                X.add(100 * a * A + 100 * b * B)
    X.remove(0)

    Y = set()
    for c in range(F//C+1):
        for d in range(F//D+1):
            if c * C + d * D <= F/2:
                Y.add((c * C + d * D))

    ans = (0, 0)
    max_dens = 0
    for x in X:
        for y in Y:
            if x + y > F:
                break
            elif y * 100 <= x * E:
                dens = y/(x+y)
                if dens > max_dens:
                    ans = (x+y, y)
                    max_dens = dens
    print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, readline().rstrip().split())
    X = set()
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if 100 * a * A + 100 * b * B <= F:
                X.add(100 * a * A + 100 * b * B)
    X.remove(0)

    Y = set()
    for c in range(F//C+1):
        for d in range(F//D+1):
            if c * C + d * D <= F/2:
                Y.add((c * C + d * D))

    ans = (0, 0)
    max_dens = 0
    for x in X:
        for y in Y:
            if not 0 <= x + y <= F:
                continue
            if y * 100 <= x * E:
                dens = y/(x+y)
                if 1.0 >= dens > max_dens:
                    ans = (x+y, y)
                    max_dens = dens
    print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, readline().rstrip().split())
    X = set()
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if 100 * a * A + 100 * b * B <= F:
                X.add(100 * a * A + 100 * b * B)
    X.remove(0)

    Y = set()
    for c in range(F//C+1):
        for d in range(F//D+1):
            if c * C + d * D <= F/2:
                Y.add((c * C + d * D))

    ans = (0, 0)
    max_dens = 0
    for x in X:
        for y in Y:
            if x + y > F:
                break
            if y * 100 <= x * E:
                dens = y/(x+y)
                if 1.0 >= dens > max_dens:
                    ans = (x+y, y)
                    max_dens = dens
    print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, readline().rstrip().split())
    X = set()
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if 100 * a * A + 100 * b * B <= F:
                X.add(100 * a * A + 100 * b * B)
    X.remove(0)

    Y = set()
    for c in range(F//C+1):
        for d in range(F//D+1):
            if c * C + d * D <= F:
                Y.add((c * C + d * D))

    ans = (0, 0)
    max_dens = 0
    for x in X:
        for y in Y:
            if x + y > F:
                break
            if y * 100 <= x * E:
                dens = y/(x+y)
                if dens > max_dens:
                    ans = (x+y, y)
                    max_dens = dens

    print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, readline().rstrip().split())
    X = set()
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if 100 * a * A + 100 * b * B <= F:
                X.add(100 * a * A + 100 * b * B)
    X.remove(0)

    Y = set()
    for c in range(F//C+1):
        for d in range(F//D+1):
            if c * C + d * D <= F/2:
                Y.add((c * C + d * D))

    ans = (0, 0)
    max_dens = 0
    for x in X:
        for y in Y:
            if x + y > F:
                break
            if y * 100 <= x * E:
                dens = y/(x+y)
                if dens > max_dens:
                    ans = (x+y, y)
                    max_dens = dens

    print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
satoumizu=1
satou=0
for a in range(31):
  for b in range(16):
    for c in range(F-100*A*a-100*B*b):
      for d in range(F-100*A*a-100*B*b-C*c):
        if a==0 and b==0 and c==0 and d==0:
          continue
        if E*(A*a+B*b)>=C*c+D*d and 100*(A*a+B*b)+C*c+D*d<=F:
          if (C*c+D*d)/(100*(A*a+B*b)+C*c+D*d)>satou/satoumizu:
            satoumizu=100*(A*a+B*b)+C*c+D*d
            satou=C*c+D*d
print(satoumizu,satou)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = [int(i) for i in input().split()]

sugar_ratio = 0
weight_a = 0
weight_sugar = 0





for i in range(a):
    if i*100 > f:
        break
    for j in range(b):
        if (i+j)*100 > f:
            break
        else:
            max_sug = e*(j+i)
            max_weight = f - (i+j)*100
            max_c = min(max_sug,max_weight)//c
            
            for k in range(max_c+1):
                max_d = ((max_sug - c*k)//d)*d
                if max_sug == 0:
                    max_sug = float('inf')
                ratio = (c*k + max_d) / max_sug 
                if ratio > sugar_ratio:
                    sugar_ratio = ratio
                    weight_a = (i+j)*100 + c*k + max_d
                    weight_sugar =  c*k + max_d
                
print(weight_a,weight_sugar)

Submission status: Wrong Answer

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

s=[]
w=[]

max = 0
ans = [100*a,0]
for i in range(s_max//c+1):
    for j in range(s_max//d+1):
        if c*i + d*j <= s_max:
            s.append(c*i + d*j)

for i in range(w_max//a+1):
    for j in range(w_max//b+1):
        if 0<a*i + b*j <= w_max:
            w.append(a*i + b*j)

for i in range(len(s)):
    for j in range(len(w)):
        if s[i]/(w[j]*100+s[i])<=e/(e+100) and s[i]/(w[j]*100+s[i])>max:
            max = s[i]/(w[j]*100+s[i])
            ans = [w[j]*100+s[i],s[i]]

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

Submission status: Wrong Answer

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

s=[]
w=[]

max = 0
ans = [100,0]
for i in range(s_max//c+1):
    for j in range(s_max//d+1):
        if c*i + d*j <= s_max:
            s.append(c*i + d*j)

for i in range(w_max//a+1):
    for j in range(w_max//b+1):
        if 0<a*i + b*j <= w_max:
            w.append(a*i + b*j)

for i in range(len(s)):
    for j in range(len(w)):
        if s[i]/(w[j]*100+s[i])<=e/(e+100) and s[i]/(w[j]*100+s[i])>max:
            max = s[i]/(w[j]*100+s[i])
            ans = [w[j]*100+s[i],s[i]]

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

Submission status: Wrong Answer

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

s=[]
w=[]

max = 0
ans = []
for i in range(s_max//c+1):
    for j in range(s_max//d+1):
        if c*i + d*j <= s_max:
            s.append(c*i + d*j)

for i in range(w_max//a+1):
    for j in range(w_max//b+1):
        if 0<a*i + b*j <= w_max:
            w.append(a*i + b*j)

for i in range(len(s)):
    for j in range(len(w)):
        if s[i]/(w[j]*100+s[i])<=e/(e+100) and s[i]/(w[j]*100+s[i])>max:
            max = s[i]/(w[j]*100+s[i])
            ans = [w[j]*100+s[i],s[i]]

print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int,input().split())
answer_number = [0,0,0,0]
answer_max = 0
for i in range((F//(100*A))+1):
  for j in range(((F-100*A*i)//(100*B))+1):
    if i==0 and j ==0: continue
    for k in range(((F-100*A*i-100*B*j)//C)+1):
      for l in range(((F-100*A*i-100*B*j-C*k)//D)+1):
        if (C*k+D*l)/(A*i+B*j) <= E:
          if (C*k+D*l)/(A*i+B*j) > answer_max:
            answer_max = (C*k+D*l)/(A*i+B*j)      #### k
            answer_number = [i,j,k,l]
if answer_number == [0,0,0,0]: print(100*B,0)
else:
  print(C*answer_number[2]+D*answer_number[3]+100*(A*answer_number[0]+B*answer_number[1]), C*answer_number[2]+D*answer_number[3])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int,input().split())
answer_number = [0,0,0,0]
answer_max = 0
for i in range((F//(100*A))+1):
  for j in range(((F-100*A*i)//(100*B))+1):
    if i==0 and j ==0: continue
    for k in range(((F-100*A*i-100*B*j)//C)+1):
      for l in range(((F-100*A*i-100*B*j-C*k)//D)+1):
        if (C*k+D*l)/(A*i+B*j) <= E:
          if (C*k+D*l)/(A*i+B*j) > answer_max:
            answer_max = (C*k+D*l)/(A*i+B*j)      #### k
            answer_number = [i,j,k,l]
if answer_number == [0,0,0,0]: print(0,0)
else:
  print(C*answer_number[2]+D*answer_number[3]+100*(A*answer_number[0]+B*answer_number[1]), C*answer_number[2]+D*answer_number[3])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int,input().split())
answer_number = [0,0,0,0]
answer_max = 0
for i in range((F//(100*A))+1):
  for j in range(((F-100*A*i)//(100*B))+1):
    if i==0 and j ==0: continue
    for k in range(((F-100*A*i-100*B*j)//C)+1):
      for l in range(((F-100*A*i-100*B*j-C*k)//D)+1):
        if (C*k+D*l)/(A*i+B*j) <= E:
          if (C*k+D*l)/(A*i+B*j) > answer_max:
            answer_max = (C*k+D*l)/(A*i+B*j)      #### k
            answer_number = [i,j,k,l]
if answer_number == [0,0,0,0]: print(0,0)
else:
  print(C*answer_number[2]+D*answer_number[3]+100*(A*answer_number[0]+B*answer_number[1]), C*answer_number[2]+D*answer_number[3])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int,input().split())
answer_number = [0,0,0,0]
answer_max = 0
for i in range((F//(100*A))+1):
  for j in range(((F-100*A*i)//(100*B))+1):
    if i==0 and j ==0: continue
    for k in range(((F-100*A*i-100*B*j)//C)+1):
      for l in range(((F-100*A*i-100*B*j-C*k)//D)+1):
        if (C*k+D*l)/(A*i+B*j) <= E:
          if (C*k+D*l)/(A*i+B*j) > answer_max:
            answer_max = (C*k+D*l)/(A*i+B*j)      #### k
            answer_number = [i,j,k,l]
print(C*answer_number[2]+D*answer_number[3]+100*(A*answer_number[0]+B*answer_number[1]), C*answer_number[2]+D*answer_number[3])

Submission status: Wrong Answer

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

w = []
s = []
max_s = int(E*F/(100+E)) 
max_c = float(E/(100+E))
ans_ws = 0
ans_s= 0


for i in range(30):
    for j in range(30):
        w.append(100*A*i+100*B*j)
w.remove(0)
w = list(set(w))


for i in range(max_s+1):
    for j in range(max_s+1):
        s.append(C*i+D*j)
s.remove(0)
s = list(set(s))


C = 0
for i in range(len(s)):
    for j in range(len(w)):
        c = float(s[i]/(s[i]+w[j]))
        if (C < c <= max_c) and (s[i]+w[j] <= F):
            C = c
            ans_ws = s[i]+w[j]
            ans_s= s[i]

print("%s %s"%(ans_ws,ans_s))

Submission status: Wrong Answer

Solution code:
import math

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

highest = 0
sugarwater = 0
maxsugar = 0
amax = math.ceil(f / (100 * a))
bmax = math.ceil(f / (100 * b))
cmax = 31
dmax = 31
for aa in range(amax):
    for bb in range(bmax):
        water = 100 * (aa * a + bb * b)
        if water == 0 or water > f:
            continue
        for cc in range(31):
            for dd in range(31):
                sugar = cc * c + dd * d
                if sugar / (water / 100) > e or water + sugar > f:
                    continue
                density = 100 * sugar / (water + sugar)
                if density >= highest:
                    highest = density
                    sugarwater = sugar + water
                    maxsugar = sugar
print(sugarwater, maxsugar)

Submission status: Wrong Answer

Solution code:
import math

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

highest = 0
sugarwater = 0
maxsugar = 0
amax = math.ceil(f / (100 * a))
bmax = math.ceil(f / (100 * b))
cmax = 31
dmax = 31
for aa in range(amax):
    for bb in range(bmax):
        water = 100 * (aa * a + bb * b)
        if water == 0 or water > f:
            continue
        for cc in range(31):
            for dd in range(31):
                sugar = cc * c + dd * d
                if sugar / (water / 100) > e or water + sugar > f:
                    continue
                density = 100 * sugar / (water + sugar)
                if density > highest:
                    highest = density
                    sugarwater = sugar + water
                    maxsugar = sugar
print(sugarwater, maxsugar)

Submission status: Wrong Answer

Solution code:
import math

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

highest = 0
sugarwater = 0
maxsugar = 0
amax = math.ceil(f / (100 * a))
bmax = math.ceil(f / (100 * b))
cmax = 31
dmax = 31
for aa in range(amax):
    for bb in range(bmax):
        water = 100 * (aa * a + bb * b)
        if water == 0 or water > f:
            continue
        for cc in range(31):
            for dd in range(31):
                sugar = cc * c + dd * d
                if sugar == 0 or sugar / (water / 100) > e or water + sugar > f:
                    continue
                density = 100 * sugar / (water + sugar)
                if density > highest:
                    highest = density
                    sugarwater = sugar + water
                    maxsugar = sugar
print(sugarwater, maxsugar)

Submission status: Wrong Answer

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

MAX_SUGER = E*F/(E+100)


water = [min(A,B)*100,max(A,B)*100]
for i in range(1,31):
    for j in range(1,31):
        water.append(100*A*i+100*B*j)
water = sorted(list(set(water)))

suger = []
for i in range(31):
    for j in range(31):
        if C*i + D*j <= MAX_SUGER:
            suger.append(C*i+D*j)
suger = sorted(list(set(suger)))

ans = []
for s in suger:
    min_water = 100*s/E
    for w in water:
        if w >= min_water:
            ans.append([s/(w+s),w+s,s])
            break
ans.sort(reverse=True)
for c,w,s in ans:
    if w <= F:
        print(w,s)
        break

Submission status: Wrong Answer

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

MAX_SUGER = E*F/(E+100)


water = [min(A,B)*100,max(A,B)*100]
for i in range(1,300):
    for j in range(1,300):
        water.append(100*A*i+100*B*j)
water = sorted(list(set(water)))

suger = []
for i in range(1000):
    for j in range(1000):
        if C*i + D*j <= MAX_SUGER:
            suger.append(C*i+D*j)
suger = sorted(list(set(suger)))

ans = []
for s in suger:
    min_water = 100*s/E
    for w in water:
        if w >= min_water:
            ans.append([s/(w+s),w+s,s])
            break
ans.sort(reverse=True)
for c,w,s in ans:
    print(c,w,s)
    if w <= F:
        print(w,s)
        break

Submission status: Wrong Answer

Solution code:
import math

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

highest = 0
sugarwater = 0
maxsugar = 0
for aa in range(math.ceil(f / (100 * a))):
    for cc in range(math.ceil(f / c)):
        for bb in range(math.ceil(f / (100 * b))):
            for dd in range(math.ceil(f / d)):
                sugar = cc * c + dd * d
                water = 100 * (aa * a + bb * b)
                if (
                    sugar == 0
                    or water == 0
                    or sugar / (water / 100) > e
                    or water + sugar > f
                ):
                    continue
                density = 100 * sugar / (water + sugar)
                if density > highest:
                    highest = density
                    sugarwater = sugar + water
                    maxsugar = sugar
print(sugarwater, maxsugar)

Submission status: Wrong Answer

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

MAX_SUGER = E*F/(E+100)


water = [min(A,B)*100,max(A,B)*100]
for i in range(1,300):
    for j in range(1,300):
        water.append(100*A*i+100*B*j)
water = sorted(list(set(water)))

suger = []
for i in range(1000):
    for j in range(1000):
        if C*i + D*j <= MAX_SUGER:
            suger.append(C*i+D*j)
suger = sorted(list(set(suger)))

ans = []
for s in suger:
    min_water = 100*s/E
    if min_water > F:
        continue
    for w in water:
        if w >= min_water:
            ans.append([s/(w+s),w+s,s])
            break
ans.sort(reverse=True)
print(ans[0][1],ans[0][2])

Submission status: Wrong Answer

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

MAX_SUGER = E*F/(E+100)


water = [min(A,B)*100,max(A,B)*100]
for i in range(1,300):
    for j in range(1,300):
        water.append(100*A*i+100*B*j)
water = sorted(list(set(water)))

suger = []
for i in range(1000):
    for j in range(1000):
        if C*i + D*j <= MAX_SUGER:
            suger.append(C*i+D*j)
suger = sorted(list(set(suger)))

ans = []
for s in suger:
    min_water = 100*s/E
    for w in water:
        if w >= min_water:
            ans.append([s/(w+s),w+s,s])
            break
ans.sort(reverse=True)
print(ans[0][1],ans[0][2])

Submission status: Wrong Answer

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

MAX_SUGER = E*F/(E+100)


water = [min(A,B)*100,max(A,B)*100]
for i in range(1,31):
    for j in range(1,31):
        water.append(100*A*i+100*B*j)
water = sorted(list(set(water)))

suger = []
for i in range(120):
    for j in range(120):
        if C*i + D*j <= MAX_SUGER:
            suger.append(C*i+D*j)
suger = sorted(list(set(suger)))

ans = []
for s in suger:
    min_water = 100*s/E
    for w in water:
        if w >= min_water:
            ans.append([s/(w+s),w+s,s])
            break
ans.sort(reverse=True)
print(ans[0][1],ans[0][2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
data=list(map(int, input().split()))
suger=0
water=0
cnt=0
na=int(data[5]/(100*data[0]))
nb=int(data[5]/(100*data[1]))
calc_data =[] #water,suger,rate
for j in range(0,nb+1):
	for i in range(0,na+1):
		water = i*data[0] + j*data[1]
		suger=0
		while suger+data[3]<=water*data[4]:
			suger += data[3]
		while suger+data[2]<=water*data[4]:
			suger += data[2]
		if (suger+water)!=0:
			rate=100*suger/(suger+100*water)
		else:
			rate=0
		if water*100+suger<=data[5]:
			calc_data.append([100*water,suger,rate])
		else:
			calc_data.append([100*water,suger,0])
		cnt+=1
max_ = calc_data[0]
for i in range(1,len(calc_data)):
	if calc_data[i][2]>max_[2]:
		max_=calc_data[i]
print(max_[0]+max_[1],max_[1])

Submission status: Wrong Answer

Solution code:
data=list(map(int, input().split()))
suger=0
water=0
cnt=0
na=int(data[5]/(100*data[0]))
nb=int(data[5]/(100*data[1]))
calc_data =[] #water,suger,rate
for j in range(0,nb+1):
	for i in range(0,na+1):
		water = i*data[0] + j*data[1]
		suger=0
		while suger+data[3]<=water*data[4]:
			suger += data[3]
		while suger+data[2]<=water*data[4]:
			suger += data[2]
		if (suger+water)!=0:
			rate=100*suger/(suger+100*water)
		else:
			rate=0
		if water*100+suger<=data[5]:
			calc_data.append([100*water,suger,rate])
		else:
			calc_data.append([100*water,suger,0])
		cnt+=1
max_ = calc_data[0]
for i in range(1,len(calc_data)):
	if calc_data[i][2]>max_[2]:
		max_=calc_data[i]
print([max_[0]+max_[1],max_[1]])

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import math

[A, B, C, D, E, F] = list(map(int, stdin.readline().rstrip().split()))

## F
# F >= 100 * A * a + 100 * B * b + C * c + D * d

## E
# C * c + D * d <= (100 * A * a + 100 * B * b) * E / 100
# 100 * (C * c + D * d) <= (100 * A * a + 100 * B * b) * E
# 100 * (C * c + D * d) / (100 * A * a + 100 * B * b) <= E


maximum_ratio = 0
max_a = 0
max_b = 0
max_c = 0
max_d = 0

for a in range(F // (100 * A) + 1):
    for b in range(F // (100 * B) + 1):
        for c in range(F // 2 // C + 1):
            for d in range(F // 2 // D + 1):
                if 100 * A * a + 100 * B * b + C * c + D * d <= F:
                    if 0 == (100 * A * a + 100 * B * b):
                        continue

                    sugar_ratio = 100 * (C * c + D * d) / (100 * A * a + 100 * B * b)
                    if E >= sugar_ratio and maximum_ratio < sugar_ratio:
                        maximum_ratio = sugar_ratio
                        max_a = a
                        max_b = b
                        max_c = c
                        max_d = d
                else:
                    break

print("%d %d" % (100 * A * max_a + 100 * B * max_b + C * max_c + D * max_d, C * max_c + D * max_d))

Submission status: Wrong Answer

Solution code:
def resolve():
    A, B, C, D, E, F = list(map(int, input().split()))
    target = 100*E/(100+E)
    result_con = float("inf")
    result_all = 0
    result_suger = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    total = 100*A*i + 100*B*j + C*k + D*l
                    suger = C*k + D*l
                    if total == 0:
                        continue
                    if total - suger == 0:
                        break
                    if total > F:
                        break
                    con = 100*suger/total
                    if con > target:
                        break
                    if result_con < con:
                        result_con = con
                        result_all = total
                        result_suger = suger
    print("{} {}".format(result_all, result_suger))


if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    A, B, C, D, E, F = list(map(int, input().split()))
    target = 100*E/(100+E)
    result_con = 0
    result_all = 0
    result_suger = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    total = 100*A*i + 100*B*j + C*k + D*l
                    suger = C*k + D*l
                    if total == 0:
                        continue
                    if total - suger == 0:
                        break
                    if total > F:
                        break
                    con = 100*suger/total
                    if con > target:
                        break
                    if result_con < con:
                        result_con = con
                        result_all = total
                        result_suger = suger
    print("{} {}".format(result_all, result_suger))


if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10 ** 7)

    wa, wb, sc, sd, se, mf = map(int, input().split())

    memo = dict()

    conc = 0
    water = 0
    sugar = 0

    def dfs(a, b, c, d):
        nonlocal conc, water, sugar

        if (a, b, c, d) in memo:
            return
        memo[a, b, c, d] = 1

        t_water = 100 * (a * wa + b * wb)
        t_sugar = c * sc + d * sd
        if t_water + t_sugar > mf:
            return
        if t_water // 100 * se < t_sugar:
            return
        t_conc = 100 * t_sugar / (t_water + t_sugar)
        if t_conc > conc:
            conc = t_conc
            water = t_water
            sugar = t_sugar

        dfs(a + 1, b, c, d)
        dfs(a, b + 1, c, d)
        dfs(a, b, c + 1, d)
        dfs(a, b, c, d + 1)

    dfs(1, 0, 0, 0)
    dfs(0, 1, 0, 0)

    print(water + sugar, sugar)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()

Submission status: Wrong Answer

Solution code:
def resolve():
    A, B, C, D, E, F = list(map(int, input().split()))
    target = 100*E/(100+E)
    result_con = 0
    result_all = 0
    result_suger = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    total = 100*A*i + 100*B*j + C*k + D*l
                    suger = C*k + D*l
                    if total - suger == 0:
                        break
                    if total > F:
                        break
                    con = 100*suger/total
                    if con > target:
                        break
                    if result_con < con:
                        result_con = con
                        result_all = total
                        result_suger = suger
    print("{} {}".format(result_all, result_suger))


if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc074/tasks/arc083_a
# 要復習
A, B, C, D, E, F = read_ints()


# Aを何回を行うか Bを何回行うかは全探索できる #30通り*30通り(たかだか)
satou_candi = set()
for c, d in product(range(3001), repeat=2):
    if c * C + d * D > F:
        continue
    satou_candi.add(c * C + d * D)

water_candi = set()
for a, b in product(range(31), repeat=2):
    if 100 * (A * a + B * b) > F:
        continue
    water_candi.add((A * a + B * b) * 100)

satou_candi = sorted(satou_candi)
water_candi = sorted(water_candi)
# print(satou_candi)
# print(water_candi)

ans_satou = 0
ans_total = A * 100

for water in water_candi[1:]:
    max_satou = E * water // 100  # 100lあたり
    idx = bisect_right(satou_candi, max_satou) - 1  # -1にはならないはず [0]→0なので
    satou = satou_candi[idx]
    # print(water, satou, max_satou)
    if satou + water > F:
        continue
    if ans_satou / ans_total <= satou / (satou + water):
        ans_satou = satou
        ans_total = water + satou

print(ans_total, ans_satou)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc074/tasks/arc083_a
# 要復習
A, B, C, D, E, F = read_ints()


# Aを何回を行うか Bを何回行うかは全探索できる #30通り*30通り(たかだか)
satou_candi = set()
for c, d in product(range(3001), repeat=2):
    if c * C + d * D > F:
        continue
    satou_candi.add(c * C + d * D)

water_candi = set()
for a, b in product(range(31), repeat=2):
    if 100 * (A * a + B * b) > F:
        continue
    water_candi.add((A * a + B * b) * 100)

satou_candi = sorted(satou_candi)
water_candi = sorted(water_candi)
# print(satou_candi)
# print(water_candi)

ans_satou = 0
ans_total = A * 100

for water in water_candi[1:]:
    max_satou = E * water // 100  # 100lあたり
    idx = bisect_right(satou_candi, max_satou) - 1  # -1にはならないはず [0]→0なので
    satou = satou_candi[idx]
    # print(water, satou, max_satou)
    if satou + water > F:
        continue
    if ans_satou / ans_total < satou / (satou + water):
        ans_satou = satou
        ans_total = water + satou

print(ans_total, ans_satou)