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:
x =  list(map(int, input().split()))
max_per = 100*(x[4]) / 100
now_max_per = 0
ansSugarWater = 0
ansSugar = 0
for B in range(int(x[5]/(100*x[1]))):
    for A in range(int((x[5]-100*B*x[1])/(100*x[0]))+ 1):
        now_sugar = 0
        can_sugar = max_per * (x[0]*A + x[1]*B)
        if can_sugar + 100*x[0]*A + 100*x[1]*B > x[5]:
            can_sugar = x[5] - 100*x[0]*A - 100*x[1]*B
        i = [0,0]
        for D in range(int(can_sugar / x[3] + 1)):
            for C in range(int((can_sugar - D*x[3])/x[2])+ 1):
                if C*x[2] + D*x[3] > now_sugar:
                    now_sugar = C*x[2] + D*x[3]
                    i = [C, D]
        C = i[0]
        D = i[1]
        if  A == 0 and B == 0:
            continue
        elif C*x[2] + D*x[3] > can_sugar:
            continue
        else:
            now_per = 100 * (C*x[2] + D*x[3]) / (100*(A*x[0] + B*x[1]) + C*x[2] + D*x[3])
        if now_per > now_max_per :
            now_max_per = now_per
            ansSugarWater = 100 * (A*x[0] + B*x[1]) + C*x[2] + D*x[3]
            ansSugar = C*x[2] + D*x[3]
print("{0} {1}".format(ansSugarWater, ansSugar))

Submission status: Wrong Answer

Solution code:
x =  list(map(int, input().split()))
max_per = 100*(x[4]) / 100
now_max_per = 0
ansSugarWater = 0
ansSugar = 0
for B in range(int(x[5]/(100*x[1]))):
    for A in range(int((x[5]-100*B*x[1])/(100*x[0]))+ 1):
        now_sugar = 0
        can_sugar = max_per * (x[0]*A + x[1]*B)
        if can_sugar + 100*x[0]*A + 100*x[1]*B > x[5]:
            can_sugar = x[5] - 100*x[0]*A - 100*x[1]*B
        i = [0,0]
        for D in range(int(can_sugar / x[3] + 1)):
            for C in range(int((can_sugar - D*x[3])/x[2])+ 1):
                if C*x[2] + D*x[3] > now_sugar:
                    now_sugar = C*x[2] + D*x[3]
                    i = [C, D]
        C = i[0]
        D = i[1]
        if  A == 0 and B == 0:
            now_per = 0
        else:
            now_per = 100 * (C*x[2] + D*x[3]) / (100*(A*x[0] + B*x[1]) + C*x[2] + D*x[3])
        if now_per > now_max_per :
            now_max_per = now_per
            ansSugarWater = 100 * (A*x[0] + B*x[1]) + C*x[2] + D*x[3]
            ansSugar = C*x[2] + D*x[3]
print("{0} {1}".format(ansSugarWater, ansSugar))

Submission status: Wrong Answer

Solution code:
A , B , C , D , E , F = map(int ,input().split())
ans = (100*A , 0)
for a in range(0,F,100*A):
    for b in range(0,F,100*B):
        water = a + b
        for c in range(0,F,C):
            for d in range(0,F,D):
                sugar = c + d
                if water + sugar > F or 100*sugar > E*water or water ==0:
                    break
                elif 100*sugar == E*water:
                    print(water,sugar)
                elif sugar*ans[0] > ans[1]*water:
                    ans = (water , sugar)
print(sum(ans),ans[1])

Submission status: Wrong Answer

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


def isOK(x, y, z, w):
    return 100 * (x * a + y * b) + z * c + w * d <= f and z * c + w * d <= e * (x * a + y * b)


m = 0
ax, ay, az, aw = 0, 0, 0, 0
for x in range(100):
    if not isOK(x, 0, 0, 0):
        break
    for y in range(100):
        if not isOK(x, y, 0, 0):
            break
        for z in range(10000):
            if not isOK(x, y, z, 0):
                break
            for w in range(10000):
                if not isOK(x, y, z, w):
                    break
                if x == 0 and y == 0 and z == 0 and w == 0:
                    continue
                p = (z * c + w * d) / (100 * (x * a + y * b) + z * c + w * d)
                if p > m:
                    m = p
                    ax, ay, az, aw = x, y, z, w

print("{0} {1}".format(100 * (ax * a + ay * b) + az * c + aw * d, az * c + aw * d))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# Editorial solution for question C

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

waterCombinations = {0}
sugarCombinations = {0}

while True:
    copy = set(waterCombinations)
    for i in copy:
        m = (i+a) * 100
        n = (i+b) * 100
        if m <= f:
            waterCombinations.add(m)
        if n <= f:
            waterCombinations.add(n)
    if copy==waterCombinations:
        break

while True:
    copy = set(sugarCombinations)
    for i in copy:
        m = i+c
        n = i+d
        if m <= f:
            sugarCombinations.add(m)

        if n <= f:
            sugarCombinations.add(n)
    if copy==sugarCombinations:
        break


best = 0
bestWater = 1
bestSugar = 1
for i in waterCombinations:
    for j in sugarCombinations:
        maxSugarAllowed = e*(i/100)
        if i+j > 0:
            l = (100 * j) / (i + j)
            if best <= l and j <= maxSugarAllowed and i+j <= f:
                bestWater = i
                bestSugar = j
                best = l
print(bestWater + bestSugar, bestSugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 1
ans_sato = 0
pat = []
mizu = set()
for i in range(int(F/100)+1):
    for j in range(int(F/100)+1):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo/C)+1):
        for j in range(int(howaryo/D)+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato
    pat.append([ans_mizu+ans_sato,ans_sato])
    ans_mizu = 1
    ans_sato = 0
    
pat.sort(key = lambda x:x[1]/(x[0]+x[1]), reverse = True)
print(pat[0][0],pat[0][1])

Submission status: Wrong Answer

Solution code:

A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0
pat = []
mizu = set()
for i in range(int(F/100)+1):
    for j in range(int(F/100)+1):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo/C)+1):
        for j in range(int(howaryo/D)+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato
    pat.append([ans_mizu+ans_sato,ans_sato])
    ans_mizu = 100
    ans_sato = 0
    
pat.sort(key = lambda x:x[1]/(x[0]+x[1]), reverse = True)
print(pat[0][0],pat[0][1])

Submission status: Wrong Answer

Solution code:
# Editorial solution for question C

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

waterCombinations = {0}
sugarCombinations = {0}

l = True
while True:
    copy = set(waterCombinations)
    for i in copy:
        m = (i+a) * 100
        n = (i+b) * 100
        if m <= f:
            waterCombinations.add(m)
        else:
            l = False
            break
        if n <= f:
            waterCombinations.add(n)
        else:
            l = False
            break
    if not l:
        break

l = True
while True:
    copy = set(sugarCombinations)
    for i in copy:
        m = i+c
        n = i+d
        if m <= f:
            sugarCombinations.add(m)
        else:
            l = False
            break
        if n <= f:
            sugarCombinations.add(n)
        else:
            l = False
            break
    if not l:
        break

best = 0
bestWater = 1
bestSugar = 1
for i in waterCombinations:
    for j in sugarCombinations:
        maxSugarAllowed = e*(i/100)
        if i+j > 0:
            l = (100 * j) / (i + j)
            if best <= l and j <= maxSugarAllowed and i+j <= f:
                bestWater = i
                bestSugar = j
                best = l
print(bestWater + bestSugar, bestSugar)

Submission status: Wrong Answer

Solution code:
# Editorial solution for question C

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

waterCombinations = {0}
sugarCombinations = {0}

l = True
while True:
    copy = set(waterCombinations)
    for i in copy:
        m = (i+a) * 100
        n = (i+b) * 100
        if m < f:
            waterCombinations.add(m)
        else:
            l = False
            break
        if n < f:
            waterCombinations.add(n)
        else:
            l = False
            break
    if not l:
        break

l = True
while True:
    copy = set(sugarCombinations)
    for i in copy:
        m = i+c
        n = i+d
        if m < f:
            sugarCombinations.add(m)
        else:
            l = False
            break
        if n < f:
            sugarCombinations.add(n)
        else:
            l = False
            break
    if not l:
        break

best = 0

for i in waterCombinations:
    for j in sugarCombinations:
        maxSugarAllowed = e*(i/100)
        if i+j > 0:
            l = (100 * j) / (i + j)
            if best <= l and j <= maxSugarAllowed and i+j <= f:
                bestWater = i
                bestSugar = j
                best = l
print(bestWater + bestSugar, bestSugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

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

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(howaryo):
        for j in range(howaryo):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:

A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

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

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo/C)+1):
        for j in range(int(howaryo/D)+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:

A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(int(F/100)):
    for j in range(int(F/100)):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo/C)+1):
        for j in range(int(howaryo/D)+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(int(F/100)):
    for j in range(int(F/100)):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo//C)+100):
        for j in range(int(howaryo//D)+100):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:

A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(int(F/(100*A))+100):
    for j in range(int(F/(100*B))+100):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo//C)+100):
        for j in range(int(howaryo//D)+100):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(int(F/(100*A))+10):
    for j in range(int(F/(100*B))+10):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo//C)+10):
        for j in range(int(howaryo//D)+10):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:

A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(int(F/(100*max(A,B)))+1):
    for j in range(int(F/(100*min(A,B)))+1):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

mizu.remove(0)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(int(howaryo//C)+1):
        for j in range(int(howaryo//D)+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:

A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(1,int(F/(100*min(A,B)))+1):
    for j in range(int(F/(100*max(A,B)))+1):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(1,int(howaryo//min(C,D))+1):
        for j in range(int(howaryo//max(C,D))+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(1,int(F/(100*min(A,B)))+1):
    for j in range(int(F/(100*max(A,B)))+1):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(1,int(howaryo//max(C,D))+1):
        for j in range(int(howaryo//min(C,D))+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

ans_mizu = 100
ans_sato = 0

mizu = set()
for i in range(1,int(F/(100*A))+1):
    for j in range(int(F/(100*B))+1):
        if 100*A*i + 100*B*j <= F:
            mizu.add(100*A*i+100*B*j)

for m in mizu:
    howaryo = (m*E)//100
    for i in range(1,int(howaryo//C)+1):
        for j in range(int(howaryo//D)+1):
            sato = C*i + D*j
            if (m + sato <= F) & (sato <= howaryo):
                if (ans_sato/(ans_mizu+ans_sato)) < (sato/(m+sato)):
                    ans_mizu = m
                    ans_sato = sato

print(ans_mizu+ans_sato,ans_sato)

Submission status: Wrong Answer

Solution code:

A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

mizu1 = 100 * min(A,B)
howaryo1 = (mizu1/100) * E
max_sato1 = 0

for i in range(int(howaryo1/C)+1):
    for j in range(int(howaryo1//D)+1):
        sato = C*i + D*j
        if (mizu1+sato <= F) & (sato <= howaryo1):
            max_sato1 = max(sato, max_sato1)
            
mizu2 = 100 * max(A,B)
howaryo2 = (mizu2/100) * E
max_sato2 = 0

for i in range(int(howaryo2/C)+1):
    for j in range(int(howaryo2//D)+1):
        sato = C*i + D*j
        if (mizu2+sato <= F) & (sato <= howaryo2):
            max_sato2 = max(sato, max_sato2)

if (max_sato1/(mizu1+max_sato1)) > (max_sato2/(mizu2+max_sato2)):
    print(mizu1+max_sato1,max_sato1)
else:
    print(mizu2+max_sato2,max_sato2)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
# A:水を100Ag　B:水を100Bg C:砂糖をCg D:砂糖をDg E:100gあたりの溶ける最大量　F:入れられる物質の質量の限界

mizu = 100 * min(A,B)
howaryo = (mizu/100) * E
max_sato = 0

for i in range(int(howaryo/C)+1):
    for j in range(int(howaryo//D)+1):
        sato = C*i + D*j
        if (mizu+sato <= F) & (sato <= howaryo):
            max_sato = max(sato, max_sato)
            
print(mizu+max_sato, max_sato)

Submission status: Wrong Answer

Solution code:
key_list = ["wA","wB","sC","sD","sugar","max"]
val = "17 19 22 26 55 2802"
val = "1 2 1 2 100 1000"
val_list = list(map(int,val.split()))
val_list = list(map(int,input().split()))

dic = dict(zip(key_list, val_list))

m_density=0
m_sugar=0
m_water=0
limit_density=dic['sugar']/(100+dic['sugar'])

for A in range(0, int(30/dic['wA'])+1):
    for B in range(0, int(30/dic['wB'])+1):
        water = 100*dic['wA']*A + 100*dic['wB']*B
        if(water > dic['max']):
            break
        if((dic['max']-water)*m_density > (dic['max']-water)):
            break
        else:
            limit = int(water*limit_density) if water < dic['max']/2 else int((dic['max']-water)*limit_density)
        for C in range(0, limit+1):
            for D in range(0, limit+1):
                sugar = dic['sC']*C + dic['sD']*D

                total = water + sugar
                density = sugar / total if total > 0 else 0
                if(total > dic['max']):
                    break
                elif(density > limit_density):
                    break
                elif(density > m_density):
                    m_density=density
                    m_sugar=sugar
                    m_water=water


print(m_sugar + m_water, " ", m_sugar)

Submission status: Wrong Answer

Solution code:
key_list = ["wA","wB","sC","sD","sugar","max"]
val_list = list(map(int,input().split()))

dic = dict(zip(key_list, val_list))


m_density=0
m_sugar=0
m_water=0

for A in range(0, int(30/dic['wA'])+1):
    for B in range(0, int(30/dic['wB'])+1):
        water = 100*dic['wA']*A + 100*dic['wB']*B
        if(water > dic['max']):
            break
        else:
            limit = water if water < dic['max']/2 else (dic['max'] - water)
        for C in range(0, limit+1):
            for D in range(0, limit+1):
                sugar = dic['sC']*C + dic['sD']*D

                total = water + sugar
                if total == 0:
                    density = 0
                else:
                    density = sugar / total
                # print(water, "", sugar, A, B, C, D)
                if(total > dic['max']):
                    break
                elif(density > dic['sugar']/(100+dic['sugar'])):
                    continue
                elif(density > m_density):
                    m_density=density
                    m_sugar=sugar
                    m_water=water


print(m_sugar + m_water, " ", m_sugar)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
def FS():
    ans = (100*A,0)
    for a in range(0,F,100*A):
        for b in range(0,F,100*B):
            for c in range(0,F,C):
                for d in range(0,F,D):
                    wat,sug = (a + b),(c + d)
                    if wat == 0 or sug == 0 or wat+sug > F or 100*sug > E*wat:
                        break
                    elif 100*sug == E*wat:
                        return (wat,sug)
                    elif sug*ans[0] > ans[1]*wat:
                        ans = (wat,sug)  
    return ans
ans = FS()
print(sum(ans),ans[1])

Submission status: Wrong Answer

Solution code:
key_list = ["wA","wB","sC","sD","sugar","max"]
val_list = list(map(int,input().split()))

dic = dict(zip(key_list, val_list))


m_density=0
m_sugar=0
m_water=0

for A in range(0,30):
    for B in range(0,15):
        for C in range(0,1500):
            for D in range(0,750):
                water = 100*dic['wA']*A + 100*dic['wB']*B
                sugar = dic['sC']*C + dic['sD']*D
                # print(water, "", sugar, A, B, C, D)

                total = water + sugar
                if total == 0:
                    density = 0
                else:
                    density = sugar / total

                if(total > dic['max']):
                    break
                elif(density > dic['sugar']/(100+dic['sugar'])):
                    continue
                elif(density > m_density):
                    m_density=density
                    m_sugar=sugar
                    m_water=water

print(m_sugar + m_water, " ", m_sugar)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc074/tasks/arc083_a
WA
"""
import sys
from sys import stdin
input = stdin.readline


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

    w = []
    s = []
    for i in range(int(F/100/A+1)):
        for j in range(int(F/100/B+1)):
            water = 100*A*i + 100*B*j
            if  water <= F and water > 0:
                w.append(water)

    for i in range(int(F/C+1)):
        for j in range(int(F/D+1)):
            sugar = C*i + D*j
            if sugar <= F and sugar > 0:
                s.append(sugar)

    record_density = 0.0
    record = [0, w[0]]
    for i in w:
        for j in s:
            if i+j <= F:
                density = (100 * j) / (i + j)
                if density > record_density:
                    if E*i/100 >= j:
                        record_density = density
                        record = [i+j, j]

    print(*record)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
def func(a, b):
    a = float(a)
    b = float(b)
    try:
        return float((100 * b) / (a + b))
    except:
        return 0

A, B, C, D, E, F = map(float, raw_input().split())

w = []
s = []

F = int(F)

for i in range(F + 1):
    for j in range(F + 1):
        if i*100*A + j*100*B <= F:
            w.append(i * 100 * A + j * 100 * B)
        else:
            break


maxes = [0, 0]

for k in w:
    for i in range(F + 1):
        for j in range(F + 1):
            tmp = i*C + j*D
            if int(tmp + k) <= F:
                if func(k, tmp) <= func(100.0, E):
                    if func(k, tmp) > func(maxes[0], maxes[1]):
                        maxes[0], maxes[1] = k, tmp
                else:
                    break
            else:
            	break

print int(maxes[0] + maxes[1]), int(maxes[1])

Submission status: Wrong Answer

Solution code:
def func(a, b):
    a = float(a)
    b = float(b)
    try:
        return float((100 * b) / (a + b))
    except:
        return 0

A, B, C, D, E, F = map(float, raw_input().split())

w = []
s = []

F = int(F)

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


maxes = [w[0], 0]

for k in w:
    for i in range(F):
        for j in range(F):
            tmp = i*C + j*D
            if int(tmp + k) <= F:
                if func(k, tmp) <= func(100.0, E):
                    if func(k, tmp) > func(maxes[0], maxes[1]):
                        maxes[0], maxes[1] = k, tmp
                else:
                    break
            else:
            	break

print int(maxes[0] + maxes[1]), int(maxes[1])

Submission status: Wrong Answer

Solution code:
def func(a, b):
    a = float(a)
    b = float(b)
    try:
        return float((100 * b) / (a + b))
    except:
        return 0

A, B, C, D, E, F = map(float, raw_input().split())

w = []
s = []

F = int(F)

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

maxes = [0, 0]

for k in w:
    for i in range(F):
        for j in range(F):
            tmp = i*C + j*D
            if int(tmp + k) <= F:
                if func(k, tmp) <= func(100.0, E):
                    if func(k, tmp) > func(maxes[0], maxes[1]):
                        maxes[0], maxes[1] = k, tmp
                else:
                    break
            else:
            	break

print int(maxes[0] + maxes[1]), int(maxes[1])

Submission status: Wrong Answer

Solution code:
def func(a, b):
    a = float(a)
    b = float(b)
    try:
        return float((100 * b) / (a + b))
    except:
        return 0

A, B, C, D, E, F = map(float, raw_input().split())

w = []
s = []

F = int(F)

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

maxes = [0, 0]

for k in w:
    for i in range(F):
        for j in range(F):
            tmp = i*C + j*D
            if int(tmp + k) <= F:
                if func(k, tmp) <= func(100.0, E) and func(k, tmp) > func(maxes[0], maxes[1]):
                    maxes[0], maxes[1] = k, tmp
            else:
            	break

print int(maxes[0] + maxes[1]), int(maxes[1])

Submission status: Wrong Answer

Solution code:
def func(a, b):
    a = float(a)
    b = float(b)
    try:
        return float((100 * b) / (a + b))
    except:
        return 0

A, B, C, D, E, F = map(float, raw_input().split())

w = []
s = []

F = int(F)

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

maxes = [0, 0]

for k in w:
    for i in range(F):
        for j in range(F):
            tmp = i*C + j*D
            if int(tmp + k) <= F:
                if func(k, tmp) <= func(100.0, E) and func(k, tmp) > func(maxes[0], maxes[1]):
                    maxes[0], maxes[1] = k, tmp
                else:
                    break

print int(maxes[0] + maxes[1]), int(maxes[1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc074/tasks/arc083_a
WA
"""
import sys
from sys import stdin
input = stdin.readline


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

    w = []
    s = []
    for i in range(int(F/100/A+1)):
        for j in range(int(F/100/B+1)):
            water = 100*A*i + 100*B*j
            if  water <= F and water > 0:
                w.append(water)

    for i in range(int(F/C+1)):
        for j in range(int(F/D+1)):
            sugar = C*i + D*j
            if sugar <= F and sugar > 0:
                s.append(sugar)

    max_density = (100*E) / (100 + E)
    record_density = 0.0
    record = [0, w[0]]
    for i in w:
        for j in s:
            if i+j <= F:
                density = (100 * j) / (i + j)
                if density > record_density and density <= max_density:
                    record_density = density
                    record = [i+j, j]

    print(*record)


if __name__ == '__main__':
    main(sys.argv[1:])