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_con = 0
max_con = E/(100+E)*100

a = 0
while F >= 100*A*a:
    b = 0
    while F-100*A*a >= 100*B*b:
        c = 0
        while F-100*(A*a+B*b) >= C*c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//D)
            mass = water + sugar
            if mass == 0:
                break
            con = sugar/mass*100
            if ans_con < con <= max_con:
                ans_con = con
                ans_mass = mass
                ans_sugar = sugar
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

Submission status: Wrong Answer

Solution code:
def solve(A, B, C, D, E, F):
    sugers = set()
    for i in range(0, F // C + 1):
        for j in range(0, F // D + 1):
            s = (C * i + D * j)
            if s + 100 * s / E <= F:
                sugers.add(C * i + D * j)
            else:
                break
    sugers = sorted(list(sugers))

    waters = set()
    for i in range(0, F // A + 1):
        for j in range(0, F // B + 1):
            if (A * i + B * j) * 100 <= F:
                waters.add(A * i + B * j)
            else:
                break
    waters = sorted(list(waters))

    dense, w_all, w_suger = 0, waters[0] * 100, 0
    for s in sugers:
        for w in waters:
            if s + 100 * w <= F and s <= w * E and w + s > 0:
                densei = 100 * s / (100 * w + s)
                if dense < densei:
                    dense = densei
                    w_all = s + 100 * w
                    w_suger = s
                    break
    return " ".join([str(w_all), str(w_suger)])


if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(" "))
    print(solve(A, B, C, D, E, F))

Submission status: Wrong Answer

Solution code:
def solve(A, B, C, D, E, F):
    sugers = set()
    for i in range(0, F // C + 1):
        for j in range(0, F // D + 1):
            s = (C * i + D * j)
            if s + 100 * s / E <= F:
                sugers.add(C * i + D * j)
            else:
                break
    sugers = sorted(list(sugers))

    waters = set()
    for i in range(0, F // A + 1):
        for j in range(0, F // B + 1):
            if (A * i + B * j) * 100 <= F:
                waters.add(A * i + B * j)
            else:
                break
    waters = sorted(list(waters))

    dense, w_all, w_suger = 0, waters[0], 0
    for s in sugers:
        for w in waters:
            if s + 100 * w <= F and s <= w * E and w + s > 0:
                densei = 100 * s / (100 * w + s)
                if dense < densei:
                    dense = densei
                    w_all = s + 100 * w
                    w_suger = s
                    break
    return " ".join([str(w_all), str(w_suger)])

if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(" "))
    print(solve(A, B, C, D, E, F))

Submission status: Wrong Answer

Solution code:
def solve(A, B, C, D, E, F):
    sugers = set()
    for i in range(0, F // A + 1):
        for j in range(0, F // B + 1):
            s = (C * i + D * j)
            if s + 100 * s / E <= F:
                sugers.add(C * i + D * j)
            else:
                break
    sugers = sorted(list(sugers))

    waters = set()
    for i in range(0, F // C + 1):
        for j in range(0, F // D + 1):
            if (A * i + B * j) * 100 <= F:
                waters.add(A * i + B * j)
            else:
                break
    waters = sorted(list(waters))

    dense, w_all, w_suger = 0, waters[0], 0
    for s in sugers:
        for w in waters:
            if s + 100 * w <= F and s <= w * E and w + s > 0:
                densei = 100 * s / (100 * w + s)
                if dense < densei:
                    dense = densei
                    w_all = s + 100 * w
                    w_suger = s
                    break
    return " ".join([str(w_all), str(w_suger)])

if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(" "))
    print(solve(A, B, C, D, E, F))

Submission status: Wrong Answer

Solution code:
def solve(A, B, C, D, E, F):
    sugers = set()
    for i in range(0, F // A + 1):
        for j in range(0, F // B + 1):
            s = (C * i + D * j)
            if s + 100 * s / E <= F:
                sugers.add(C * i + D * j)
            else:
                break
    sugers = sorted(list(sugers))

    waters = set()
    for i in range(0, F // C + 1):
        for j in range(0, F // D + 1):
            if (A * i + B * j) * 100 <= F:
                waters.add(A * i + B * j)
            else:
                break
    waters = sorted(list(waters))

    dense, w_all, w_suger = 0, 0, 0
    for s in sugers:
        for w in waters:
            if s + 100 * w <= F and s <= w * E and w + s > 0:
                densei = 100 * s / (100 * w + s)
                if dense < densei:
                    dense = densei
                    w_all = s + 100 * w
                    w_suger = s
                    break
    return " ".join([str(w_all), str(w_suger)])


if __name__ == "__main__":
    A, B, C, D, E, F = map(int, input().split(" "))
    print(solve(A, B, C, D, E, F))

Submission status: Wrong Answer

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

W = set()
for a in range(0, F+1, 100*A):
    for b in range(0, F+1-a, 100*B):
        W.add(a+b)

S = set()
for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        S.add(c+d)

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

Submission status: Wrong Answer

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

def res(water, sugar, memo):
    if water + sugar > F:
        return None
    if (water, sugar) in memo:
        return None
    if water + sugar == 0:
        pass
    elif E*(water+sugar) >= sugar*(100+E):
        memo[(water, sugar)] = sugar/(water+sugar)
    else:
        memo[(water, sugar)] = 0

    res(water+100*A, sugar, memo)
    res(water+100*B, sugar, memo)
    res(water, sugar+C, memo)
    res(water, sugar+D, memo)
    return memo

memo = res(0, 0, {})
k, v = max(memo.items(), key=lambda x:x[1])
print(k[0]+k[1], k[1])

Submission status: Wrong Answer

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

def res(water, sugar, memo):
    if water + sugar > F:
        return None
    if (water, sugar) in memo:
        return None
    if water + sugar == 0:
        memo[(water, sugar)] = 0
    elif E*(water+sugar) >= sugar*(100+E):
        memo[(water, sugar)] = sugar/(water+sugar)
    else:
        memo[(water, sugar)] = 0

    res(water+100*A, sugar, memo)
    res(water+100*B, sugar, memo)
    res(water, sugar+C, memo)
    res(water, sugar+D, memo)
    return memo

memo = res(0, 0, {})
k, v = max(memo.items(), key=lambda x:x[1])
print(k[0]+k[1], k[1])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F//100+1)]
dp[0][0] = True
for i in range(F//100+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = 0.0
argi, argj = 0, 0
for i in range(F//100+1):
    for j in range(F+1):
        if j == 0:
            continue
        if dp[i][j]:
            if j/(100*i+j) >= dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F+1)]
dp[0][0] = True
for i in range(F//100+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = 0.0
argi, argj = 0, 0
for i in range(F+1):
    for j in range(F+1):
        if j == 0:
            continue
        if dp[i][j]:
            if j/(100*i+j) >= dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F+1)]
dp[0][0] = True
for i in range(F+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = 0.0
argi, argj = 0, 0
for i in range(F+1):
    for j in range(F+1):
        if j == 0:
            continue
        if dp[i][j]:
            if j/(100*i+j) >= dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F+1)]
dp[0][0] = True
for i in range(F+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = 0.0
argi, argj = 0, 0
for i in range(F+1):
    for j in range(F+1):
        if j == 0:
            continue
        if dp[i][j]:
            if j/(100*i+j) > dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F+1)]
dp[0][0] = True
for i in range(F+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if i == j == 0:
            continue
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = 0.0
argi, argj = 0, 0
for i in range(F+1):
    for j in range(F+1):
        if j == 0:
            break
        if dp[i][j]:
            if j/(100*i+j) > dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F+1)]
dp[0][0] = True
for i in range(F+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if i == j == 0:
            break
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = 0.0
argi, argj = 0, 0
for i in range(F+1):
    for j in range(F+1):
        if i == j == 0:
            break
        if dp[i][j]:
            if j/(100*i+j) > dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F+1)]
dp[0][0] = True
for i in range(F+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if i == j == 0:
            break
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = 0.0
argi, argj = -1, -1
for i in range(F+1):
    for j in range(F+1):
        if i == j == 0:
            break
        if dp[i][j]:
            if j/(100*i+j) > dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F+1)]
dp[0][0] = True
for i in range(F+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if i == j == 0:
            break
        dp[i][j] = dp[i][j-C] or dp[i][j-D] or dp[i-A][j] or dp[i-B][j]

dense = 0.0
argi, argj = -1, -1
for i in range(F+1):
    for j in range(F+1):
        if i == j == 0:
            break
        if dp[i][j]:
            if j/(100*i+j) > dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)

Submission status: Wrong Answer

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

def calcCons(nA, nB, nC, nD):
    W = nA*a*100 + nB*b*100
    S = nC*c + nD*d
    if W+S == 0:
        return -1
    return 100*S/(W+S)


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


maxCons = 0
answer_W, answer_S = 0, 0

nA, nB, nC, nD = 0, 0, 0, 0
while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
    # Operation A
    while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
        # Operation B
        while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
            # Operation C
            while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
                # Operation D
                cons = calcCons(nA, nB, nC, nD)
                # print("{} {} {} {} {}".format(cons, nA, nB, nC, nD))
                if cons > maxCons and cons <= 100*e/(100+e):
                    maxCons = cons
                    answer_W, answer_S = nA*a*100 + nB*b*100, nC*c + nD*d
                nD += 1
            nD = 0
            nC += 1
        nC = 0
        nB += 1
    nB = 0
    nA += 1

print("{} {}".format(int(answer_W+answer_S), int(answer_S)))

Submission status: Wrong Answer

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

def calcCons(nA, nB, nC, nD):
    W = nA*a*100 + nB*b*100
    S = nC*c + nD*d
    if W+S == 0:
        return -1
    return 100*S/(W+S)


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


maxCons = 0
answer_W, answer_S = 0, 0

nA, nB, nC, nD = 0, 0, 0, 0
while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
    # Operation A
    while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
        # Operation B
        while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
            # Operation C
            while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
                # Operation D
                cons = calcCons(nA, nB, nC, nD)
                # print("{} {} {} {} {}".format(cons, nA, nB, nC, nD))
                if cons > maxCons and cons <= 100*e/(100+e):
                    maxCons = cons
                    answer_W, answer_S = nA*a*100 + nB*b*100, nC*c + nD*d
                nD += 1
            nD = 0
            nC += 1
        nC = 0
        nB += 1
    nB = 0
    nA += 1

print("{} {}".format(answer_W+answer_S, answer_S))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
w = set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s = set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)
ans = 0
sugerwater = 0
suger = 0
for x in w:
    for y in s:
        if  0<x+y<=f and y <= x*e//100:
            if ans < y/(x+y):
                ans = y/(x+y)
                sugerwater = x+y
                suger = y
print(sugerwater,suger)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
w = set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s = set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)
ans = 0
sugerwater = 0
suger = 0
for x in w:
    for y in s:
        if  0<x+y<=f and y <= x*e/100:
            if ans < y/(x+y):
                ans = y/(x+y)
                sugerwater = x+y
                suger = y
print(sugerwater,suger)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
w = set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s = set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)
ans = 0
sugerwater = 0
suger = 0
for x in w:
    for y in s:
        if 0<x and 0<x+y<=f and y <= x*e/100:
            if ans < y/(x+y):
                ans = y/(x+y)
                sugerwater = x+y
                suger = y
print(sugerwater,suger)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
w = set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s = set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)
ans = 0
sugerwater = 0
suger = 0
for x in w:
    for y in s:
        if 0<x and 0<x+y<=f and y <= x*e/100:
            if ans < y/(x+y):
                ans = y/(x+y)
                sugerwater = x+y
                suger = y
print(x,y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
w = set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s = set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)
ans = 0
sugerwater = 0
suger = 0
for x in w:
    for y in s:
        if 0<x+y<=f and 100*y/(x+y) <= e:
            if ans < y/(x+y):
                ans = y/(x+y)
                sugerwater = x+y
                suger = y
print(x,y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def dense(a, b):
    try:
        return 100 * b / (a + b)
    except ZeroDivisionError:
        return 0


A, B, C, D, E, F = il()
A *= 100
B *= 100
max_dense = 0
max_water = 0
max_sugar = 0
for a in range(31):
    for b in range(31):
        water = a * A + b * B
        if water == 0:
            break
        for c in range((F - water) // C + 1):
            for d in range((F - water) // D + 1):
                sugar = c * C + d * D
                if water + sugar > F or water / 100 * E < sugar:
                    break
                if max_dense < dense(water, sugar):
                    max_dense = dense(water, sugar)
                    max_water = water
                    max_sugar = sugar
print(max_water + max_sugar, max_sugar)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def dense(a, b):
    try:
        return 100 * b / (a + b)
    except ZeroDivisionError:
        return 0


A, B, C, D, E, F = il()
A *= 100
B *= 100
max_dense = 0
max_water = 0
max_sugar = 0
for a in range(F // A):
    for b in range(31):
        water = a * A + b * B
        if water == 0:
            break
        for c in range((F - water) // C + 1):
            for d in range((F - water) // D + 1):
                sugar = c * C + d * D
                if water + sugar > F or water / 100 * E < sugar:
                    break
                if max_dense < dense(water, sugar):
                    max_dense = dense(water, sugar)
                    max_water = water
                    max_sugar = sugar
print(max_water + max_sugar, max_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
limwater = F // 100
waterdp = [False] * (limwater + 1)
waterdp[0] = True
for i in range(1, limwater + 1):
	if i >= A and waterdp[i - A]:
		waterdp[i] = True
	if i >= B and waterdp[i - B]:
		waterdp[i] = True
sugardp = [False] * (F + 1)
sugardp[0] = True
for i in range(1, F + 1):
	if i >= C and sugardp[i - C]:
		sugardp[i] = True
	if i >= D and sugardp[i - D]:
		sugardp[i] = True
waterans = 0
sugarans = 0
maxdensity = 0.0
for i in range(1, limwater + 1):
	for j in range(0, F + 1):
		if waterdp[i] and sugardp[j] and i * 100 + j <= F:
			density = j / (i * 100 + j)
			if density <= E / (100 + E) and density > maxdensity:
				maxdensity = density
				waterans = i
				sugarans = j
print(waterans * 100 + sugarans, sugarans)

Submission status: Wrong Answer

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

water = []
for a in range(31):
    for b in range(31):
        if 100 * a * A + 100* b * B <= F:
            water.append(100 * a * A + 100 * b * B)
water = list(set(water))
water.remove(0)

sugar = []

for c in range(3001):
    for d in range(3001):
        if c * C + d * D <= F:
            sugar.append(c * C + d * D)
sugar = list(set(sugar))
sugar.remove(0)

memo = []
for w in water:
    for s in sugar:
        if w + s <= F and s/(w+s) <= E/(100+E):
            memo.append([s/(s+w),w+s, s])
memo.sort(reverse=True)
if len(memo) == 0:
    print(A, 0)
else:
    print(memo[0][1], memo[0][2])

Submission status: Wrong Answer

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

water = []
for a in range(31):
    for b in range(31):
        if 100 * a * A + 100* b * B <= F:
            water.append(a * A + b * B)
water = list(set(water))
water.remove(0)

sugar = []

for c in range(3001):
    for d in range(3001):
        if c * C + d * D <= F:
            sugar.append(c * C + d * D)
sugar = list(set(sugar))
sugar.remove(0)

memo = []
for w in water:
    for s in sugar:
        if w + s <= F and 100*s/(w+s) <= E:
            memo.append([s/(s+a),w+s, s])
memo.sort(reverse=True)
if len(memo) == 0:
    print(A, 0)
else:
    print(memo[0])

Submission status: Wrong Answer

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

water = []
for a in range(31):
    for b in range(31):
        if a * A + b * B <= F:
            water.append(a * A + b * B)
water = list(set(water))
water.remove(0)

sugar = []

for c in range(3001):
    for d in range(3001):
        if c * C + d * D <= F:
            sugar.append(c * C + d * D)
sugar = list(set(sugar))
sugar.remove(0)

memo = []
for w in water:
    for s in sugar:
        if w + s <= F and 100*s/(w+s) <= E:
            memo.append([s/(s+a),w+s, s])
memo.sort(reverse=True)
if len(memo) == 0:
    print(A, 0)
else:
    print(memo[0])

Submission status: Wrong Answer

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

ans=0
Wit=0
Cnc=0

for a in range(30):
    if a*A>30:
        break
    for b in range(31):
        if b*B>30:
            break
        for c in range(3000):
            if a*A*100+b*B*100+c*C>F:
                break
            for d in range(3000):
                if 0<a*A*100+b*B*100+c*C+d*D>F:
                    break
                else:
                    if a==0 and b==0:
                        pass
                    else:
                        if (c*C*100+d*D*100)<=E*(a*A*100+b*B*100):
                            if ans<((c*C*100+d*D*100)/(a*A*100+b*B*100)):
                                ans=((c*C*100+d*D*100)/(a*A*100+b*B*100))
                                Wit=(a*A*100+b*B*100+c*C+d*D)
                                Cnc=(c*C+d*D)
                                #print(c,d)
print(Wit,Cnc)

Submission status: Wrong Answer

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

water = []
suger = []
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 100*a*i + 100*b*j <= f and 100*a*i + 100*b*j not in water:
            water.append(100*a*i+100*b*j)

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = [f//a*a,0]
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

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

Submission status: Wrong Answer

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

water = []
suger = []
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 100*a*i + 100*b*j <= f and 100*a*i + 100*b*j not in water:
            water.append(100*a*i+100*b*j)

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = [f,0]
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

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

Submission status: Wrong Answer

Solution code:
def abc074_c():
    from math import ceil
    a, b, c, d, e, f = map(int, input().split())
    ans_wat = 100
    ans_sug = 0

    for i in range(ceil(f / (100 * a))):
        for j in range(ceil((f - 100 * a * i) / (100 * b))):
            for k in range((f - 100 * (a * i + b * j)) // c + 1):
                for l in range((f - 100 * (a * i + b * j) - c * k) // d + 1):
                    tmp_sug = c * k + d * l
                    tmp_wat = 100 * (a * i + b * j)
                    if tmp_wat and tmp_wat + tmp_sug <= f and tmp_sug / tmp_wat <= e / 100 and \
                            tmp_sug / (tmp_wat + tmp_sug) > ans_sug / (ans_wat + ans_sug):
                        ans_sug = c * k + d * l
                        ans_wat = 100 * (a * i + b * j)
    print(ans_wat + ans_sug, ans_sug)


abc074_c()

Submission status: Wrong Answer

Solution code:
def abc074_c():
    from math import ceil
    a, b, c, d, e, f = map(int, input().split())
    ans_wat = 100
    ans_sug = 0

    for i in range(ceil(f / (100 * a))):
        for j in range(ceil((f - 100 * a * i) / (100 * b))):
            for k in range((f - 100 * (a * i + b * j)) // c + 1):
                for l in range((f - 100 * (a * i + b * j) - c * k) // d + 1):
                    tmp_sug = c * k + d * l
                    tmp_wat = 100 * (a * i + b * j)
                    if tmp_wat and tmp_sug / tmp_wat <= e / 100 and \
                            tmp_sug / (tmp_wat + tmp_sug) > ans_sug / (ans_wat + ans_sug):
                        ans_sug = c * k + d * l
                        ans_wat = 100 * (a * i + b * j)
    print(ans_wat + ans_sug, ans_sug)


abc074_c()

Submission status: Wrong Answer

Solution code:
def abc074_c():
    from math import ceil
    a, b, c, d, e, f = map(int, input().split())
    ans_wat = 100
    ans_sug = 0

    for i in range(ceil(f / (100 * a))):
        for j in range(ceil((f - 100 * a * i) / (100 * b))):
            for k in range(ceil((f - 100 * (a * i + b * j)) / c)):
                for l in range(ceil((f - 100 * (a * i + b * j) - c * k) / d)):
                    tmp_sug = c * k + d * l
                    tmp_wat = 100 * (a * i + b * j)
                    if tmp_wat and tmp_sug / tmp_wat <= e / 100 and \
                            tmp_sug / (tmp_wat + tmp_sug) > ans_sug / (ans_wat + ans_sug):
                        ans_sug = c * k + d * l
                        ans_wat = 100 * (a * i + b * j)
    print(ans_wat + ans_sug, ans_sug)


abc074_c()