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

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range((F-C*i)//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D
        y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        if i == j == 0:
            continue
        tmp_x = i * A * 100 + j * B * 100
        x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 1
ans_sugar = -1
ans_density = -1
density = E/(100+E)
#print("density: ",density)
for m in x:
    for n in y:
        tmp_density = n/(m+n)
        if m + n <= F and m/100*E >= n and ans_sugar/ans_sweetwater <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            #ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range((F-C*i)//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D
        y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        if i == j == 0:
            continue
        tmp_x = i * A * 100 + j * B * 100
        x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 1
ans_sugar = -1
ans_density = -1
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and m/100*E >= n and ans_sugar/ans_sweetwater <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            #ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range((F-C*i)//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D
        y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        if i == j == 0:
            continue
        tmp_x = i * A * 100 + j * B * 100
        x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 1
ans_sugar = -1
ans_density = -1
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and m/100*E >= n and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range((F-C*i)//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D
        y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        if i == j == 0:
            continue
        tmp_x = i * A * 100 + j * B * 100
        x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = -1
ans_density = -1
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and m/100*E >= n and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range((F-C*i)//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D
        y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        if i == j == 0:
            continue
        tmp_x = i * A * 100 + j * B * 100
        x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = -1
ans_density = 0
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and m/100*E >= n and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range((F-C*i)//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D

        if tmp_y <= F:
            y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        if i == j == 0:
            continue

        tmp_x = i * A * 100 + j * B * 100

        if tmp_x <= F:
            x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = 0
ans_density = 0
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and m/100*E >= n and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range(F-C*i//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D

        if tmp_y <= F:
            y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range(F-(100*A*i)//(100*B)+1):
        if i == j == 0:
            continue

        tmp_x = i * A * 100 + j * B * 100

        if tmp_x <= F:
            x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = 0
ans_density = 0
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and m/100*E >= n and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range(F-C*i//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D

        if tmp_y <= F:
            y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range(F-(100*A*i)//(100*B)+1):
        if i == j == 0:
            continue

        tmp_x = i * A * 100 + j * B * 100

        if tmp_x <= F:
            x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = 0
ans_density = 0
density = E//(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n//(m+n)
        if m + n <= F and tmp_density <= density and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F//C+1):
    for j in range(F-C*i//D+1):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D

        if tmp_y <= F:
            y.append(tmp_y)

for i in range(F//(100 * A)+1):
    for j in range(F-(100*A*i)//(100*B)+1):
        if i == j == 0:
            continue

        tmp_x = i * A * 100 + j * B * 100
        
        if tmp_x <= F:
            x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = 0
ans_density = 0
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and tmp_density <= density and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F):
    for j in range(F):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D
        tmp_x = i * A * 100 + j * B * 100
        if tmp_y <= F:
            y.append(tmp_y)
        if tmp_x <= F:
            x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = 0
ans_density = 0
density = E/(100+E)
#print("density: ",density)
for n in y:
    for m in x:
        tmp_density = n/(m+n)
        if m + n <= F and tmp_density <= density and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A,B,C,D,E,F = list(map(int, input().split()))
#x is a list which represents for the volumn of water
x = list()

#y is a list which represents for the volumn of sugar
y = list()

for i in range(F):
    for j in range(F):
        if i == j == 0:
            continue
        tmp_y = i * C + j * D
        tmp_x = i * A * 100 + j * B * 100
        if tmp_y <= F:
            y.append(tmp_y)
        if tmp_x <= F:
            x.append(tmp_x)
#print(x)
#print(y)
ans_sweetwater = 0
ans_sugar = 0
ans_density = 0
density = E/(100+E)
#print("density: ",density)
for m in x:
    for n in y:
        tmp_density = n/(m+n)
        if m + n <= F and tmp_density <= density and ans_density <= tmp_density:
            ans_sweetwater =  m + n
            ans_sugar = n
            ans_density = tmp_density
print(ans_sweetwater,ans_sugar)

Submission status: Wrong Answer

Solution code:
import math

def concentration(water, sugar):
    if water + sugar == 0:
        return -1
    else:
        return 100 * sugar / (water + sugar)


if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(' '))
    res_water = 0
    res_sugar = 0
    for ia in range(math.floor(F / (100 * A))):
        for ib in range(math.floor(F / (100 * B))):
            water = 100 * (ia * A + ib * B)
            rest = F - water
            if rest < 0:
                break
            for ic in range(math.floor(rest / C)):
                for id in range(math.floor(rest / D)):
                    sugar = ic * C + id * D
                    if rest - sugar < 0:
                        break
                    if (water / 100) * E >= sugar and \
                       concentration(res_water, res_sugar) < concentration(water, sugar):
                        res_water = water
                        res_sugar = sugar
    print(res_water + res_sugar, res_sugar)

Submission status: Wrong Answer

Solution code:
import math

def concentration(water, sugar):
    if water + sugar == 0:
        return 0
    else:
        return 100 * sugar / (water + sugar)


if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(' '))
    res_water = 0
    res_sugar = 0
    for ia in range(math.floor(F / (100 * A))):
        for ib in range(math.floor(F / (100 * B))):
            water = 100 * (ia * A + ib * B)
            rest = F - water
            if rest <= 0:
                break
            for ic in range(math.floor(rest / C)):
                for id in range(math.floor(rest / D)):
                    sugar = ic * C + id * D
                    if rest - sugar < 0:
                        break
                    if (water / 100) * E >= sugar and \
                       concentration(res_water, res_sugar) < concentration(water, sugar):
                        res_water = water
                        res_sugar = sugar
    print(res_water + res_sugar, res_sugar)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
mxy=0
my=0
pree=0
for a in range(31):
  for b in range(31):
    x=100*A*a+100*B*b
    if(x>=F):
        continue
    #ymax=int(E*x/100)
    #print(ymax,x)
    for c in range(101):
      for d in range(101):
        y=C*c+D*d
        if((x+y)==0):
            #print(0)
            continue
        e=100*y/(x+y)
        if(x+y>F or e>100*E/(100+E)):
          #print(1)
          continue
        else:
          if(e>pree):
              mxy=x+y
              my=y
              pree=e
              #print(mxy,my)
print(mxy,my)
#print(934/2634)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
mxy=0
my=0
pree=0
for a in range(31):
  for b in range(31):
    for c in range(31):
      for d in range(31):
        x=A*a+B*b
        y=C*c+D*d
        if(x+y==0):
            continue
        e=100*y/(x+y)
        if(x+y>F or e>100*E/(100+E)):
          continue
        else:
          if(e>pree):
              mxy=x+y
              my=y
print(mxy,my)

Submission status: Wrong Answer

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

x = set()
y = set()

for i in range(F // 100 * A):
    for j in range((F - 100 * A * i) // 100 * B):
        if i + j == 0:
            continue
        x.add(A * i * 100 + B * j * 100)

for i in range(F // C):
    for j in range((F - C * i) // D):
        if i + j == 0:
            continue
        y.add(C * i + D * j)

ret_w = list(x)[0] + list(y)[0]
ret_s = list(y)[0]

for w in x:
    for s in y:
        if w + s <= F and w * E / 100 >= s and s / (w + s) >= ret_s / ret_w:
            ret_s = s
            ret_w = w + s

print(ret_w, ret_s)

Submission status: Wrong Answer

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

x = set()
y = set()

for i in range(F // 100 * A):
    for j in range((F - 100 * A * i) // 100 * B):
        if i + j == 0:
            continue
        x.add(A * i * 100 + B * j * 100)

for i in range(F // C):
    for j in range((F - C * i) // D):
        if i + j == 0:
            continue
        y.add(C * i + D * j)

ret_w = 1
ret_s = -1

for w in x:
    for s in y:
        if w + s <= F and w * E / 100 >= s and 100 * s / (w + s) >= 100 * ret_s / ret_w:
            ret_s = s
            ret_w = w + s

print(ret_w, ret_s)

Submission status: Wrong Answer

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

ret_w = 1
ret_s = 0

x = set()
y = set()

for i in range(F // 100 * A):
    for j in range((F - 100 * A * i) // 100 * B):
        if i + j == 0:
            continue
        x.add(A * i * 100 + B * j * 100)

for i in range(F // C):
    for j in range((F - C * i) // D):
        if i + j == 0:
            continue
        y.add(C * i + D * j)

for w in x:
    for s in y:
        if w + s <= F and w * E / 100 >= s and 100 * s / (w + s) >= 100 * ret_s / ret_w:
            ret_s = s
            ret_w = w + s

print(ret_w, ret_s)

Submission status: Wrong Answer

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

ret_w = 1
ret_s = 0

x = []
y = []

for i in range(F // 100 * A):
    for j in range((F - 100 * A * i) // 100 * B):
        if i + j == 0:
            continue
        x.append(A * i * 100 + B * j * 100)

for i in range(F // C):
    for j in range((F - C * i) // D):
        if i + j == 0:
            continue
        y.append(C * i + D * j)

for w in x:
    for s in y:
        if w + s <= F and w * E / 100 >= s and 100 * s / (w + s) >= 100 * ret_s / ret_w:
            ret_s = s
            ret_w = w + s

print(ret_w, ret_s)

Submission status: Wrong Answer

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

ret_w = 1
ret_s = 0
for a in range(F // (100 * A) + 1):
    w_a = a * A * 100
    for b in range((F - w_a) // (100 * B) + 1):
        if a + b == 0:
            continue
        w_b = b * B * 100

        max_suger = min(F - w_a - w_b, (w_a + w_b) * E // 100)
        for c in range(max_suger // C + 1):
            s_c = c * C
            for d in range((max_suger - c * C) // D + 1):
                s_d = d * D
                if ret_s / ret_w < (s_c + s_d) / (w_a + w_b + s_c + s_d):
                    ret_s = s_c + s_d
                    ret_w = ret_s + w_a + w_b

print(ret_w, ret_s)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


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

    w_list, s_list = [False] * 3001, [False] * 3001
    for i in range(F // (A * 100) + 1):
        for j in range(F // (B * 100) + 1):
            w = 100 * A * i + 100 * B * j
            if w <= 3000:
                w_list[w] = True
    for i in range(F // C + 1):
        for j in range(F // D + 1):
            s = C * i + D * j
            if s <= 3000:
                s_list[s] = True

    best = 0
    ans = 0, 0
    for s in range(len(s_list)):
        for w in range(len(w_list)):
            if s + w <= F and s_list[s] and w_list[w]:
                total = s + w
                if total > 0 and s <= w // 100 * E:
                    if s / total > best:
                        best = s / total
                        ans = total, s

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

maxSolve = 0
ansSolution = 0
ansSugar = 0
for x in range(0, F, 100 * A):
    for y in range(0, F, 100 * B):
        water = x + y
        if(water == 0 or water > F):
            break

        solve = E * water // 100

        z, w = 0, 0
        while (z <= solve):
            w = 0
            while (w <= solve):
                sugar = z + w
                w += D
                if sugar > solve or water + sugar > F:
                    break
                solveDegree = sugar / (sugar + water)
                if(solveDegree > maxSolve):
                    maxSolve = solveDegree
                    ansSolution = water + sugar
                    ansSugar = sugar
            z += C
print(ansSolution, ansSugar)

Submission status: Wrong Answer

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

maxSolve = 0
ansSolution = 0
ansSugar = 0
for x in range(0, F, 100 * A):
    for y in range(0, F, 100 * B):
        water = x + y
        if(water == 0 or water > F):
            break

        solve = E * water // 100

        for z in range(0, solve+1, C):
            for w in range(0, solve+1, D):
                sugar = z + w
                if sugar > solve or water + sugar > F:
                    break
                solveDegree = sugar / (sugar + water)
                if(solveDegree > maxSolve):
                    maxSolve = solveDegree
                    ansSolution = water + sugar
                    ansSugar = sugar
print(ansSolution, ansSugar)

Submission status: Wrong Answer

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


maxSolve = 0
ansSolution = 0
ansSugar = 0
for x in range(0, F, 100 * A):
    print
    for y in range(0, F, 100 * B):
        water = x + y
        if(water > F):
            break
        solve = water // 100 * E
        for z in range(0, solve, C):
            for w in range(0, solve, D):
                sugar = z + w
                if sugar > solve or water + sugar > F:
                    break
                solveDegree = sugar / (sugar + water)
                if(solveDegree > maxSolve):
                    maxSolve = solveDegree
                    ansSolution = water + sugar
                    ansSugar = sugar
print(ansSolution, ansSugar)

Submission status: Wrong Answer

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

ans_s, ans_w, ans_c = 0, 0, 0
for i in range(1+int(f/100*a)):
	for j in range(1+int((f-100*i*a)/(100*b))):
		for k in range(1+int((f-100*i*a-100*j*b)/c)):
			for l in range(1+int((f-100*i*a-100*j*b-k*c)/d)):
				s = (c * k + d * l)
				w = 100 * (i * a + j * b)
				if s + w <= f and s + w > 0:
					_c = s * 1.0 / (s + w)
					if _c > ans_c and (e * w/100) >= s:
						ans_c = _c
						ans_s = s
						ans_w = w
print(ans_s+ans_w, ans_s)

Submission status: Wrong Answer

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

a_max_sugar = a*e
b_max_sugar = b*e
a_in_sugar = 0
b_in_sugar = 0
lim = f - a*100
for i in range(0, max(a_max_sugar//c, a_max_sugar//d)+1):
    for j in range(0, min(a_max_sugar//c, a_max_sugar//d)+1):
        sugar = c*i + d*j
        if sugar <= a_max_sugar and sugar <= lim:
            a_in_sugar = max(a_in_sugar, c*i + d*j)
lim = f - b*100
for i in range(0, max(b_max_sugar//c, b_max_sugar//d)+1):
    for j in range(0, min(b_max_sugar//c, b_max_sugar//d)+1):
        sugar = c*i + d*j
        if sugar <= b_max_sugar and sugar <= lim:
            b_in_sugar = max(b_in_sugar, c*i + d*j)

if f - a*100 >= a_max_sugar and f - b*100 >= b_max_sugar:
    print(max(a*100 + a_in_sugar, b*100 + b_in_sugar), max(a_in_sugar, b_in_sugar))
elif f - a*100 >= a_max_sugar:
    print(a*100 + a_in_sugar, a_in_sugar)
else:
    print(b*100 + b_in_sugar, b_in_sugar)

Submission status: Wrong Answer

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

a_max_suger = a*e
b_max_suger = b*e
a_in_suger = 0
b_in_suger = 0
all = 0
for i in range(max(a_max_suger//c, a_max_suger//d)+1):
    for j in range(min(a_max_suger//c, a_max_suger//d)+1):
        if c*i + d*j <= a_max_suger:
            a_in_suger = max(a_in_suger, c*i + d*j)
for i in range(max(b_max_suger//c, b_max_suger//d)+1):
    for j in range(min(b_max_suger//c, b_max_suger//d)+1):
        if c*i + d*j <= b_max_suger:
            b_in_suger = max(b_in_suger, c*i + d*j)

if f - a*100 >= a_max_suger and f - b*100 >= b_max_suger:
    print(max(a*100 + a_in_suger, b*100 + b_in_suger), max(a_in_suger, b_in_suger))
elif f - a*100 >= a_max_suger:
    print(a*100 + a_in_suger, a_in_suger)
else:
    print(b*100 + b_in_suger, b_in_suger)

Submission status: Wrong Answer

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

a_max_suger = a*e
b_max_suger = b*e
a_in_suger = 0
b_in_suger = 0
all = 0
for i in range(max(a_max_suger//c, a_max_suger//d)+1):
    for j in range(min(a_max_suger//c, a_max_suger//d)+1):
        if c*i + d*j <= a_max_suger:
            a_in_suger = max(a_in_suger, c*i + d*j)
for i in range(1, max(b_max_suger//c, b_max_suger//d)+1):
    for j in range(1, min(b_max_suger//c, b_max_suger//d)+1):
        if c*i + d*j <= b_max_suger:
            b_in_suger = max(b_in_suger, c*i + d*j)

if f - a*100 >= a_max_suger and f - b*100 >= b_max_suger:
    print(max(a*100 + a_in_suger, b*100 + b_in_suger), max(a_in_suger, b_in_suger))
elif f - a*100 >= a_max_suger:
    print(a*100 + a_in_suger, a_in_suger)
else:
    print(b*100 + b_in_suger, b_in_suger)

Submission status: Wrong Answer

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

a_max_suger = a*e
b_max_suger = b*e
a_in_suger = 0
b_in_suger = 0
for i in range(max(a_max_suger//c, a_max_suger//d)+1):
    for j in range(min(a_max_suger//c, a_max_suger//d)+1):
        if c*i + d*j <= a_max_suger:
            a_in_suger = max(a_in_suger, c*i + d*j)
for i in range(1, max(b_max_suger//c, b_max_suger//d)+1):
    for j in range(1, min(b_max_suger//c, b_max_suger//d)+1):
        if c*i + d*j <= b_max_suger:
            b_in_suger = max(b_in_suger, c*i + d*j)

if f - a*100 >= a_max_suger:
    print(a*100 + a_in_suger, a_in_suger)
else:
    print(b*100 + b_in_suger, b_in_suger)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
big = a[1] * 100
small = a[0] * 100
concentration = 0
maxtotal = 0
maxsugar = 0
timesb = int(a[5] / big)
timess = int(a[5] / small)
for i in range(timesb + 1):
	waterb = big * i
	for j in range(timess + 1):
		waters = small * j
		watert = waterb + waters
		if watert >= a[5]:
			break
		else:
			for c in range(0,a[5] - watert,a[2]):
				for d in range(0,a[5] - watert - c,a[3]):
					sugart = c + d
					total = watert + sugart
					if watert != 0 and total <= a[5] and sugart <= (watert / 100) * a[4]:
						tempconcentration = (sugart / total) * 100
						if tempconcentration > concentration:
							concentration = (sugart / total) * 100
							maxtotal = total
							maxsugar = sugart
print('{0} {1}'.format(maxtotal,maxsugar))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
big = a[1] * 100
small = a[0] * 100
concentration = 0
maxtotal = 0
maxsugar = 0
timesb = int(a[5] / big)
timess = int(a[5] / small)
for i in range(timesb + 1):
	waterb = big * i
	for i in range(timess + 1):
		waters = small * i
		watert = waterb + waters
		if watert >= a[5]:
			break
		else:
			for c in range(0,a[5] - watert,a[2]):
				for d in range(0,a[5] - watert - c,a[3]):
					sugart = c + d
					total = watert + sugart
					if watert != 0 and total <= a[5] and sugart <= (watert / 100) * a[4]:
						tempconcentration = (sugart / total) * 100
						if tempconcentration > concentration:
							concentration = (sugart / total) * 100
							maxtotal = total
							maxsugar = sugart
print('{0} {1}'.format(maxtotal,maxsugar))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
big = a[1] * 100
small = a[0] * 100
concentration = 0
maxtotal = 0
maxsugar = 0
timesb = int(a[5] / big)
timess = int(a[5] / small)
for i in range(timesb + 1):
	waterb = big * i
	for i in range(timess + 1):
		waters = small * i
		watert = waterb + waters
		for c in range(0,a[5] - watert,a[2]):
			for d in range(0,a[5] - watert - c,a[3]):
				sugart = c + d
				total = watert + sugart
				if watert != 0 and total <= a[5] and sugart <= (watert / 100) * a[4]:
					tempconcentration = (sugart / total) * 100
					if tempconcentration > concentration:
						concentration = (sugart / total) * 100
						maxtotal = total
						maxsugar = sugart
print('{0} {1}'.format(maxtotal,maxsugar))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
if a[0] <= a[1]:
	big = a[1] * 100
	small = a[0] * 100
else:
	big = a[0] * 100
	small = a[1] * 100

concentration = 0
maxtotal = 0
maxsugar = 0
timesb = a[5] // big
timess = a[5] // small
for i in range(timesb + 1):
	waterb = big * i
	for i in range(timess + 1):
		waters = small * i
		watert = waterb + waters
		for c in range(0,a[5] - watert,a[2]):
			for d in range(0,a[5] - watert - c,a[3]):
				sugart = c + d
				total = watert + sugart
				if watert != 0 and total <= a[5] and sugart <= (watert / 100) * a[4]:
					tempconcentration = (sugart / total) * 100
					if tempconcentration > concentration:
						concentration = (sugart / total) * 100
						maxtotal = total
						maxsugar = sugart
print('{0} {1}'.format(maxtotal,maxsugar))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
if a[0] <= a[1]:
	big = a[1] * 100
	small = a[0] * 100
else:
	big = a[0] * 100
	small = a[1] * 100

concentration = 0
maxtotal = 0
maxsugar = 0
timesb = a[5] // big
timess = a[5] // small
for i in range(timesb + 1):
	waterb = big * i
	for i in range(timess + 1):
		waters = small * i
		watert = waterb + waters
		for c in (0,a[5],a[2]):
			for d in (0,a[5],a[3]):
				sugart = c + d
				total = watert + sugart
				if watert == 0:
					break
				elif total <= a[5] and sugart <= (watert / 100) * a[4]:
					tempconcentration = (sugart / total) * 100
					if tempconcentration > concentration:
						concentration = (sugart / total) * 100
						maxtotal = total
						maxsugar = sugart
print('{0} {1}'.format(maxtotal,maxsugar))

Submission status: Wrong Answer

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

waters = set()
sugars = set()

for i in range(0, f+1):
    for j in range(0, f+1):
        watersum = 100*a*i + 100*b*j
        if watersum == 0 or watersum > f:
            break
        waters.add(watersum)

for i in range(0, f+1):
    for j in range(0, f+1):
        sugarsum = c*i + d*j
        if sugarsum > f:
            break
        sugars.add(sugarsum)


maxx = 0
answ, anss = 0, 0

for water in waters:
    for sugar in sugars:
        if water + sugar > f or sugar*(100+e) > e*(water+sugar):
            continue
        conc = sugar / (water + sugar)
        if maxx < conc:
            maxx = conc
            answ, anss = water, sugar

print(answ+anss, anss)