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

A, B, C, D, E, F = [int(x) for x in input().split()]

ans = [0, 0, -1]

for x in range((30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F or x + y == 0:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            if b + a > F or b > (a // 100) * E:
                b = 0
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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

Submission status: Wrong Answer

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

A, B, C, D, E, F = [int(x) for x in input().split()]

ans = [0, 0, -1]

for x in range((30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F or x + y == 0:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            if b + a > F or b > (a // 100) * E:
                continue
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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

Submission status: Wrong Answer

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

A, B, C, D, E, F = [int(x) for x in input().split()]

ans = [0, 0, -1]

for x in range((30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F or x + y == 0:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            if b + a > F or b > a * E:
                continue
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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

Submission status: Wrong Answer

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

A, B, C, D, E, F = [int(x) for x in input().split()]

ans = [0, 0, -1]

for x in range(1, (30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            if b + a > F or b > a * E:
                continue
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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

Submission status: Wrong Answer

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

A, B, C, D, E, F = [int(x) for x in input().split()]

ans = [0, 0, -1]

for x in range(1, (30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            if b + a > F:
                continue
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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

Submission status: Wrong Answer

Solution code:
print(0, 0)

Submission status: Wrong Answer

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

def main():
    max_density = 0
    whole_weight = 0
    sugar_weight = 0
    A, B, C, D, E, F = map(int, input().split())
    for n_a in range(int(F / (100 * A)) + 1):
        for n_b in range(int((F - 100 * n_a * A) / (100 * B)) + 1):
            max_sugar = min(E * (n_a * A + n_b * B), F - 100 * (n_a * A + n_b * B))
            for n_c in range(int(max_sugar / C) + 1):
                for n_d in range(int((max_sugar - C * n_c) / D) + 1):
                    if 100 * (n_a * A + n_b * B) + n_c * C + n_d * D == 0:
                        continue
                    density = (n_c * C + n_d * D) / (100 * (n_a * A + n_b * B) + n_c * C + n_d * D)
                    if density > max_density:
                        max_density = density
                        whole_weight = 100 * (n_a * A + n_b * B) + n_c * C + n_d * D
                        sugar_weight = n_c * C + n_d * D
    print(whole_weight, sugar_weight)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    max_density = 0
    whole_weight = 0
    sugar_weight = 0
    A, B, C, D, E, F = map(int, input().split())
    for n_a in range(round(F / (100 * A)) + 1):
        for n_b in range(round((F - 100 * n_a * A) / (100 * B)) + 1):
            max_sugar = min(E * (n_a * A + n_b * B), F - 100 * (n_a * A + n_b * B))
            for n_c in range(round(max_sugar / C) + 1):
                for n_d in range(round((max_sugar - C * n_c) / D) + 1):
                    if 100 * (n_a * A + n_b * B) + n_c * C + n_d * D == 0:
                        continue
                    density = (n_c * C + n_d * D) / (100 * (n_a * A + n_b * B) + n_c * C + n_d * D)
                    if density > max_density:
                        max_density = density
                        whole_weight = 100 * (n_a * A + n_b * B) + n_c * C + n_d * D
                        sugar_weight = n_c * C + n_d * D
    print(whole_weight, sugar_weight)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    max_density = 0
    whole_weight = 0
    sugar_weight = 0
    A, B, C, D, E, F = map(int, input().split())
    for n_a in range(int(F / (100 * A)) + 1):
        for n_b in range(int((F - 100 * n_a * A) / (100 * B)) + 1):
            max_sugar = min(E * (n_a * A + n_b * B), F - 100 * (n_a * A + n_b * B))
            for n_c in range(int(max_sugar / C) + 1):
                for n_d in range(int((max_sugar - C * n_c) / D) + 1):
                    if 100 * (n_a * A + n_b * B) + n_c * C + n_d * D == 0:
                        continue
                    density = (n_c * C + n_d * D) / (100 * (n_a * A + n_b * B) + n_c * C + n_d * D)
                    if density > max_density:
                        max_density = density
                        whole_weight = 100 * (n_a * A + n_b * B) + n_c * C + n_d * D
                        sugar_weight = n_c * C + n_d * D
    print(whole_weight, sugar_weight)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

density = 0
max_density = 0
ans = []
for a in range(31):
    if a*A*100> F:
        break
    for b in range(31):
        if a==0 and b==0:
            continue
        if a*A*100+b*B*100>F:
            break
        for c in range(101):
            for d in range(101):
#                 print("{},{}".format(c,d))
                if c==0 and d==0:
                    ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))
                if a*A*100+b*B*100*c*C+d*D>F:
                    break
#                 print(a*A*100 + b*B*100 + c*C + d*D)
                if ( a*A*100 + b*B*100 + c*C + d*D <= F ) and ( 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D) <= 100*E/(100+E) ):
                    density = 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D)
#                     print(density)
#                     print("{} {}".format(a*A*100+b*B*100, c*C+d*D))
                    if max_density < density:
#                         print(max_density)
                        max_density = density
                        ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))


print(ans[-1])

Submission status: Wrong Answer

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

density = 0
max_density = 0
ans = []
for a in range(31):
    if a*A*100> F:
        break
    for b in range(31):
        if a==0 and b==0:
            continue
        if a*A*100+b*B*100>F:
            break
        for c in range(101):
            for d in range(101):
                print("{},{}".format(c,d))
                if c==0 and d==0:
                    print("test")
                    ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))
                if a*A*100+b*B*100*c*C+d*D>F:
                    break
#                 print(a*A*100 + b*B*100 + c*C + d*D)
                if ( a*A*100 + b*B*100 + c*C + d*D <= F ) and ( 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D) <= 100*E/(100+E) ):
                    density = 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D)
#                     print(density)
#                     print("{} {}".format(a*A*100+b*B*100, c*C+d*D))
                    if max_density < density:
#                         print(max_density)
                        max_density = density
                        ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))

if len(ans) != 0:
    print(ans[-1])
else:
    print("{} {}".format(0,0))

Submission status: Wrong Answer

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

density = 0
max_density = 0
ans = []
for a in range(31):
    if a*A*100> F:
        break
    for b in range(31):
        if a==0 and b==0:
            break
        if a*A*100+b*B*100>F:
            break
        for c in range(101):
            for d in range(101):
                if a*A*100+b*B*100*c*C+d*D>F:
                    break
#                 print(a*A*100 + b*B*100 + c*C + d*D)
                if ( a*A*100 + b*B*100 + c*C + d*D <= F ) and ( 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D) <= 100*E/(100+E) ):
                    density = 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D)
#                     print(density)
#                     print("{} {}".format(a*A*100+b*B*100, c*C+d*D))
                    if max_density < density:
#                         print(max_density)
                        max_density = density
                        ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))
if len(ans)!=0:
    print(ans[-1])
else:
    print("{} {}".format(0,0))

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = []
sugar = []
pct = 0
ans_sugar = 0
ans_tot = 0

# water
for a in range(F + 1):
	if 100 * A * a > F: break
	for b in range(F + 1):
		x = 100 * A * a + 100 * B * b
		if x <= F:
			water.append(x)
			
# sugar
for a in range(F + 1):
	if C * a > F: break
	for b in range(F + 1):
		x = C * a + D * b
		if x <= F:
			sugar.append(x)
			
for w in water:
	for s in sugar:
		if w + s == 0: continue
		if w + s <= F and E * w / 100 >= s:
			if pct < s / (w + s):
				pct = s / (w + s)
				ans_sugar = s
				ans_tot = w + s
				
print(ans_tot, end = " ")
print(ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = []
sugar = []
pct = 0
ans_sugar = 0
ans_tot = 0

# water
for a in range(F + 1):
	for b in range(F + 1):
		x = 100 * A * a + 100 * B * b
		if x <= F:
			water.append(x)
			
# sugar
for a in range(F + 1):
	for b in range(F + 1):
		x = C * a + D * b
		if x <= F:
			sugar.append(x)
			
for w in water:
	for s in sugar:
		if w + s == 0: continue
		if w + s <= F and 15 * w / 100 >= s:
			if pct < s / (w + s):
				pct = s / (w + s)
				ans_sugar = s
				ans_tot = w + s
				
print(ans_tot, end = " ")
print(ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = [int(x) for x in input().split()]
a_water = 0
a_sugar = 0
a_conc = 0
max_conc = 100 * E / (100 + E)
for i in range(F//(100*A) + 1):
    for j in range((F-i*100*A)//(100*B) + 1):
        water = i * 100 * A + j * 100 * B
        if water == 0:
            continue
        for k in range((F-water)//C + 1):
            for l in range((F-water-C*k)//D + 1):
                sugar = k * C + l * D
                conc = 100 * sugar / (water + sugar) if water + sugar > 0 else 0
                if water + sugar <= F and conc <= max_conc and a_conc < conc:
                    a_water = water
                    a_sugar = sugar
                    a_conc = conc
                else:
                    pass
print(a_water + a_sugar, a_sugar)

Submission status: Wrong Answer

Solution code:
'''
数が少ないため、全探索を実施する
'''

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

ans_w = 0
ans_s = 0
ans_density = 0
max_density = (E / (100 + E)) * 100
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        work_w = 100 * A * i + 100 * B * j
        max_sugar = F - work_w
        for k in range(max_sugar // C + 1):
            for l in range(max_sugar // D + 1):
                work_s = C * k + D * l

                # 水がなければNG
                if (work_s + work_w) == 0:
                    continue
                else:
                    work_density = 100 * work_s / (work_s + work_w)

                # 合計の重さがF以下で、100gあたりの砂糖がE以下でなければNG
                if (work_w + work_s > F) | (work_density > max_density):
                    continue

                # 濃度が現状の最大値よりも大きい場合、最大値を更新する
                if (work_density > ans_density):
                    ans_w = work_w
                    ans_s = work_s
                    ans_density = work_density

print(ans_w + ans_s, ans_s)

Submission status: Wrong Answer

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

for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        water = (i * A + j * B) * 100
        rest = F - water
        if water > F:
            continue
        for k in range(rest // C + 1):
            for l in range(rest // D + 1):
                sugar = k * C + l * D
                if water + sugar > F:
                    continue
                if sugar * 100 > water * E:
                    continue
                if sugar + water == 0:
                    density = 0
                else:
                    density = sugar / (sugar + water)
                if maxDensity < density:
                    ans_water = water
                    ans_sugar = sugar
                    maxDensity = density


print(ans_water + ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = [int(x) for x in input().split()]
a_water = 0
a_sugar = 0
a_conc = 0
max_conc = 100 * E / (100 + E)
for i in range(F//(100*A) + 1):
    for j in range((F-100*A*i)//(100*B) + 1):
        water = i * 100 * A + j * 100 * B
        for k in range((F-water)//C + 1):
            for l in range((F-water-C*k)//D + 1):
                sugar = k * C + l * D
                conc = 100 * sugar / (water + sugar) if water + sugar > 0 else 0
                if water + sugar <= F and conc <= max_conc and a_conc < conc:
                    a_water = water
                    a_sugar = sugar
                    a_conc = conc
                else:
                    pass
print(a_water + a_sugar, a_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = [int(x) for x in input().split()]
a_water = -1
a_sugar = -1
a_conc = -1
max_conc = 100 * E / (100 + E)
for i in range(F//(100*A) + 1):
    for j in range((F-100*A*i)//(100*B) + 1):
        water = i * 100 * A + j * 100 * B
        for k in range((F-water)//C + 1):
            for l in range((F-water-C*k)//D + 1):
                sugar = k * C + l * D
                conc = 100 * sugar / (water + sugar) if water + sugar > 0 else 0
                if water + sugar <= F and conc <= max_conc and a_conc < conc:
                    a_water = water
                    a_sugar = sugar
                    a_conc = conc
                else:
                    pass
print(a_water + a_sugar, a_sugar)

Submission status: Wrong Answer

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

ans_omosa = 0
ans_sugar = 0
per_checker = 0

for _a in range(f // (a * 100)+1):
    for _b in range(f // (b * 100)+1):
        for _c in range((f // c)+1):
            for _d in range((f // d)+1):
                # 砂糖溶かしすぎチェック
                if (_c * c + _d * d) > (_a * a + _b * b) * e:
                    break
                # 重さチェック
                elif (_c * c + _d * d) + (_a * a + _b * b) * 100 > f:
                    break
                elif (_a * a * 100 + _b * b * 100 + _c * c + _d * d) == 0:
                    break
                else:
                    if per_checker < (_c * c + _d * d) / (_a * a * 100 + _b * b * 100 + _c * c + _d * d):
                        per_checker = (_c * c + _d * d) / (_a * a * 100 + _b * b * 100 + _c * c + _d * d)
                        ans_omosa = (_c * c + _d * d) + (_a * a + _b * b) * 100
                        ans_sugar = (_c * c + _d * d)
                        #print(_a, a, _b, b, _c, c, _d, d)

print("{} {}".format(ans_omosa, ans_sugar))

Submission status: Wrong Answer

Solution code:
def rec_water(total):
    if total > F:
        return
    else:
        water_amount.append(total)
        rec_water(total+100*A)
        rec_water(total+100*B)


# def rec_sugar(total):
#     if total > 1500:
#         return
#     else:
#         sugar_amount.append(total)
#         rec_sugar(total+C)
#         rec_sugar(total+D)


water_amount = []
sugar_amount = []
A, B, C, D, E, F = map(int, input().split())
rec_water(0)
for i in range(1501):
    for j in range(1501):
        sugar_amount.append(i*C+D*j)
# rec_sugar(0)
water_amount = list(set(water_amount))
sugar_amount = list(set(sugar_amount))
# print(water_amount)
# print(len(sugar_amount))
ans_sugar_water = 0
ans_sugar = 0
percent = 0
water_amount.remove(0)
# 1つ目は求める砂糖水の質量, 2つ目はそれに溶けている砂糖の質量
for w in water_amount:
    for s in sugar_amount:
        if w+s > F or s > E*(w/100):
            continue
        else:
            # 濃度が高ければ更新する
            if s / (w+s) > percent:
                ans_sugar_water = w+s
                ans_sugar = s
                percent = s / (w+s)
print(ans_sugar_water, ans_sugar)

Submission status: Wrong Answer

Solution code:
def rec_water(total):
    if total > F:
        return
    else:
        water_amount.append(total)
        rec_water(total+100*A)
        rec_water(total+100*B)


# def rec_sugar(total):
#     if total > 1500:
#         return
#     else:
#         sugar_amount.append(total)
#         rec_sugar(total+C)
#         rec_sugar(total+D)


water_amount = []
sugar_amount = []
A, B, C, D, E, F = map(int, input().split())
rec_water(0)
for i in range(1501):
    for j in range(1501):
        sugar_amount.append(i*C+D*j)
# rec_sugar(0)
water_amount = list(set(water_amount))
sugar_amount = list(set(sugar_amount))
# print(water_amount)
# print(len(sugar_amount))
ans_sugar_water = 0
ans_sugar = 0
# 1つ目は求める砂糖水の質量, 2つ目はそれに溶けている砂糖の質量
for w in water_amount:
    for s in sugar_amount:
        if w+s > F or s > E*(w/100):
            continue
        else:
            if s > ans_sugar:
                ans_sugar_water = w+s
                ans_sugar = s
print(ans_sugar_water, ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a,b,c,d,e,f = map(int,readline().split())
wf = f//100+1
water = [0]*(wf+31)
suger = [0]*(f+31)

water[0] = 1
suger[0] = 1

for i in range(wf):
    if water[i]:
        water[i+a] = 1
        water[i+b] = 1
for i in range(f):
    if suger[i]:
        suger[i+c] = 1
        suger[i+d] = 1

water = set(100*i for i in range(1,wf+1) if water[i])
suger = set(i for i in range(f+1) if suger[i])

ans_per = 0.0
ans_water = 0
ans_suger = 0

for w,s in itertools.product(water,suger):
    if w//100*e < s: #砂糖が溶け残る
        continue
    if w+s > f: #重量オーバー
        continue
    res = s/(w+s) #パーセンテージ
    if res > ans_per:
        ans_per = res
        ans_water = w
        ans_suger = s

print(ans_water+ans_suger,ans_suger)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a,b,c,d,e,f = map(int,readline().split())
wf = f//100+1
water = [0]*(wf+31)
suger = [0]*(f+31)

water[0] = 1
suger[0] = 1

for i in range(wf):
    if water[i]:
        water[i+a] = 1
        water[i+b] = 1
for i in range(f):
    if suger[i]:
        suger[i+c] = 1
        suger[i+d] = 1

water = set(100*i for i in range(1,wf+1) if water[i])
suger = set(i for i in range(1,f+1) if suger[i])

ans_per = 0.0
ans_water = 0
ans_suger = 0

for w,s in itertools.product(water,suger):
    if w//100*e < s: #砂糖が溶け残る
        continue
    if w+s > f: #重量オーバー
        continue
    res = s/(w+s) #パーセンテージ
    if res > ans_per:
        ans_per = res
        ans_water = w
        ans_suger = s

print(ans_water+ans_suger,ans_suger)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a,b,c,d,e,f = map(int,readline().split())
f += 1
wf = f//100+1
water = [0]*(wf+30)
suger = [0]*(f+30)

water[0] = 1
suger[0] = 1

for i in range(wf):
    if water[i]:
        water[i+a] = 1
        water[i+b] = 1
for i in range(f):
    if suger[i]:
        suger[i+c] = 1
        suger[i+d] = 1

water = set(100*i for i in range(1,wf+1) if water[i])
suger = set(i for i in range(1,f+1) if suger[i])

ans_per = 0.0
ans_water = 0
ans_suger = 0

for w,s in itertools.product(water,suger):
    if w//100*e < s: #砂糖が溶け残る
        continue
    if w+s > f: #重量オーバー
        continue
    res = s/(w+s) #パーセンテージ
    if res > ans_per:
        ans_per = res
        ans_water = w
        ans_suger = s

print(ans_water+ans_suger,ans_suger)

Submission status: Wrong Answer

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

A*=100
B*=100

dp=[-1 for i in range(F+1)]
dp2=[-1 for i in range(F+1)]
dp[0]=0
dp2[0]=0


for i in range(1,len(dp)):
    if i>=C and dp[i-C]>=0 or i>=D and dp[i-D]>=0:
        dp[i]=i
for i in range(1,len(dp)):
    if i>=A and dp2[i-A]>=0 or i>=B and dp2[i-B]>=0:
        dp2[i]=i
#print(dp)
#print(dp2)

noud=0
rep1=0
redp2=0
saidainoudo=E/(E+100)
for p1 in dp:
    if p1!=-1:
        for p2 in dp2:
            if p2>=0:

                satousui=p1+p2
                if 0<satousui<=F:
                    tempnoud=p1/(satousui)

                    if noud<tempnoud<=saidainoudo:
                        #print(p1,p2)
                        noud=tempnoud
                        rep1=p1
                        redp2=satousui

print(redp2,rep1)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
a_count = 0
b_count = 0
c_count = 0
d_count = 0
max_per = 0.0
max_ans = [0,0]
while a_count * 100 * a <= f:
    b_count = 0
    c_count = 0
    d_count = 0
    while (a_count * a + b_count * b) * 100  <= f:
        c_count = 0
        d_count = 0
        while (a_count * a + b_count * b) * 100 + c_count * c <= f:
            d_count = 0
            while (a_count * a + b_count * b) * 100 + c_count * c + d_count * d <= f:
                #溶けてるのかどうか
                if (a_count * a + b_count * b)* e < (c_count * c + d_count * d):
                    break
                else:
                    if a_count + b_count + c_count + d_count == 0:
                        break
                    if max_per < (100 * (c_count * c + d_count * d) / ((a_count * a + b_count * b) * 100 + c_count * c + d_count * d)):
                        max_ans = [(a_count * a + b_count * b) * 100 + c_count*c + d_count*d, c_count*c + d_count * d]
                        max_per = (100 * (c_count * c + d_count * d) / ((a_count * a + b_count * b) * 100 + c_count * c + d_count * d))
                d_count += 1
            c_count += 1
        b_count += 1
    a_count += 1
print("{} {}".format(max_ans[0], max_ans[1]))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
a_count = 0
b_count = 0
c_count = 0
d_count = 0
max_per = 0
max_ans = [0,0]
while a_count * 100 * a <= f:
    b_count = 0
    c_count = 0
    d_count = 0
    while (a_count * a + b_count * b) * 100  <= f:
        c_count = 0
        d_count = 0
        while (a_count * a + b_count * b) * 100 + c_count * c <= f:
            d_count = 0
            while (a_count * a + b_count * b) * 100 + c_count * c + d_count * d <= f:
                #溶けてるのかどうか
                if (a_count * a + b_count * b)* e < (c_count * c + d_count * d):
                    break
                else:
                    if a_count + b_count + c_count + d_count == 0:
                        break
                    if max_per < (100 * (c_count * c + d_count * d) / ((a_count * a + b_count * b) * 100 + c_count * c + d_count * d)):
                        max_ans = [(a_count * a + b_count * b) * 100 + c_count*c + d_count*d, c_count*c + d_count * d]
                        max_per = (100 * (c_count * c + d_count * d) / ((a_count * a + b_count * b) * 100 + c_count * c + d_count * d))
                d_count += 1
            c_count += 1
        b_count += 1
    a_count += 1
print("{} {}".format(max_ans[0], max_ans[1]))

Submission status: Wrong Answer

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

cand = []
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                water = 100*a*i + 100*b*j
                if water == 0:
                    break
                sugar = c*k + d*l
                if water + sugar > f:
                    break
                if 100*sugar/water <= e:
                    cand.append((100*sugar//(water+sugar), water+sugar, sugar))

cand.sort(reverse=True)

if cand[0][0] == 0:
    print(100*min(a, b), 0)
else:
    print(cand[0][1], cand[0][2])

Submission status: Wrong Answer

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

cand = []
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                water = 100*a*i + 100*b*j
                if water == 0:
                    break
                sugar = c*k + d*l
                if water + sugar > f:
                    break
                if 100*sugar/water <= e:
                    cand.append((100*sugar//(water+sugar), water+sugar, sugar))

cand.sort(reverse=True)

if cand[0][0] == 0:
    print(100*a, 0)
else:
    print(cand[0][1], cand[0][2])

Submission status: Wrong Answer

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

cand = []
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                water = 100*a*i + 100*b*j
                if water == 0:
                    break
                sugar = c*k + d*l
                if water + sugar > f:
                    break
                if 100*sugar/water <= e:
                    cand.append((100*sugar//(water+sugar), water+sugar, sugar))

cand.sort(reverse=True)

if cand[0][0] == 0:
    print(0, 0)
else:
    print(cand[0][1], cand[0][2])

Submission status: Wrong Answer

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

cand = []
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                water = 100*a*i + 100*b*j
                if water == 0:
                    break
                sugar = c*k + d*l
                if water + sugar > f:
                    break
                if 100*sugar/water <= e:
                    cand.append((100*sugar//(water+sugar), water+sugar, sugar))

cand.sort(reverse=True)

print(cand[0][1], cand[0][2])

Submission status: Wrong Answer

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


dp = [0 for i in range(f//100+1)]
dp[0] = 1
for i in range(f//100+1):
    if dp[i]:
        if i + a <= f//100:
            dp[i+a] = 1
        if i + b <= f//100:
            dp[i+b] = 1
dd = [0 for i in range(f+1)]
dd[0] = 1
for i in range(f+1):
    if dd[i]:
        if i + c <= f:
            dd[i+c] = 1
        if i + d <= f:
            dd[i+d] = 1

water = [i for i in range(f//100+1) if dp[i] and i]
sugar = [i for i in range(f+1) if dd[i]]
ans = 0
ww, ss= 0,0
for w in water:
    for s in sugar:
        if w*100+s <= f and e >= s/w:
            if ans < 100 * s / (100*w+s):
                ans = 100*s / (w*100+s)
                ww,ss=w*100,s

print(ww+ss,ss)

Submission status: Wrong Answer

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


dp = [0 for i in range(f//100+1)]
dp[0] = 1
for i in range(f//100+1):
    if dp[i]:
        if i + a <= f//100:
            dp[i+a] = 1
        if i + b <= f//100:
            dp[i+b] = 1
dd = [0 for i in range(f+1)]
dd[0] = 1
for i in range(f+1):
    if dd[i]:
        if i + c <= f:
            dd[i+c] = 1
        if i + d <= f:
            dd[i+d] = 1

water = [i for i in range(f//100+1) if dp[i] and i]
sugar = [i for i in range(f+1) if dd[i]]
ans = 0
ww, ss= 0,0
for w in water:
    for s in sugar:
        if w*100+s <= f and e*w >= s:
            if ans < 100 * s / (100*w+s):
                ans = 100*s / (w*100+s)
                ww,ss=w*100,s

print(ww+ss,ss)