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 bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, C, D, E, F = LI()

    # 水と砂糖の用意できるパターンを列挙
    # 水に対して砂糖の量を2分探索
    w = set()
    for i in range(F // (100 * A) + 1):
        for j in range((F - i * 100 * A) // (100 * B) + 1):
            if i != 0 and i != 0:
                w.add(i * A + j * B)
    # print(w)

    s = set()
    for i in range(F // C + 1):
        for j in range((F - i * C) // D + 1):
            s.add(i * C + j * D)
    s = list(s)
    s.sort()
    # print(s)

    ans = [0, 0]
    c = 0
    for i in w:
        ng = len(s)
        ok = -1
        while abs(ok-ng)>1:
            m = (ng+ok)//2
            if s[m] <= E * i and s[m] + 100 * i <= F:
                ok = m
            else:
                ng = m
        if ok >= 0 and s[ok] / i > c:
            ans = [i, s[ok]]
            c = s[ok] / i

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

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, C, D, E, F = LI()

    # 水と砂糖の用意できるパターンを列挙
    # 水に対して砂糖の量を2分探索
    w = set()
    for i in range(F // (100 * A) + 1):
        for j in range((F - i * 100 * A) // (100 * B) + 1):
            if i != 0 and i != 0:
                w.add(i * A + j * B)
    # print(w)

    s = set()
    for i in range(F // C + 1):
        for j in range((F - i * C) // D + 1):
            s.add(i * C + j * D)
    s = list(s)
    s.sort()
    # print(s)

    ans = [0, 0]
    c = 0
    for i in w:
        ng = len(s)
        ok = 0
        while abs(ok-ng)>1:
            m = (ng+ok)//2
            if s[m] <= E * i and F - 100 * i > 0:
                ok = m
            else:
                ng = m
        if s[ok] / i > c:
            ans = [i, s[ok]]

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

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
from math import gcd
A,B,C,D,E,F = (int(T) for T in input().split())
SugerMax = 0
WaterMax = F
MaxFlag = False
for TC in range(1,D//gcd(C,D)):
    RestC = F-C*TC
    for TD in range(0,(RestC//D)+1):
        RestD = RestC-D*TD
        Suger = C*TC+D*TD
        if RestD>=0:
            NeedMin = (100*Suger)/E
            for TA in range(1,B//gcd(A,B)):
                for TB in range(0,(F//100)+1):
                    Water = A*TA*100+B*TB*100
                    if Water<=RestD:
                        if NeedMin<=Water and SugerMax/WaterMax<Suger/Water:
                            MaxFlag = True
                            SugerMax = Suger
                            WaterMax = Water
                    else:
                        break
        else:
            break
if MaxFlag:
    print('{} {}'.format(WaterMax+SugerMax,SugerMax))
else:
    print('{} 0'.format(A*100))

Submission status: Wrong Answer

Solution code:
water = []
a,b,c,d,e,f = map(int, input().split())
a= a*100 
b = b*100 
for i in range(f//a+1):
    for j in range(f//b+1):
        if 0<a*i+b*j<=f:
            water.append(a*i+b*j)

sugar = []
for i in range(f//c+1):
    for j in range(f//d+1):
        if 0<c*i+d*j<=f:
            sugar.append(c*i+d*j)

ans1 =0 
ans2 =0 
ans3 =0
for i in water:
    for j in sugar:
        if i+j<=f and j/i*100<=e:
            if j/(i+j) > ans3:
                ans1 = i+j 
                ans2 = j                   


print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
water = []
a,b,c,d,e,f = map(int, input().split())
a= a*100 
b = b*100 
for i in range(f//a+1):
    for j in range(f//b+1):
        if 0<a*i+b*j<=f:
            water.append(a*i+b*j)

sugar = []
for i in range(f//c+1):
    for j in range(f//d+1):
        if 0<c*i+d*j<=f:
            sugar.append(c*i+d*j)

ans1 =0 
ans2 =0 
ans3 =0
for i in water:
    for j in sugar:
        if i+j<=f and j/i*100<=e:
            if j/(i+j) > ans3:
                ans1 = i+j 
                ans2 = j

Submission status: Wrong Answer

Solution code:
water = []
a,b,c,d,e,f = map(int, input().split()) 
for i in range(f//a+1):
    for j in range(f//b+1):
        if 0<a*i+b*j<=f:
            water.append(a*i+b*j)

sugar = []
for i in range(f//c+1):
    for j in range(f//d+1):
        if 0<c*i+d*j<=f:
            sugar.append(c*i+d*j)

ans1 =0 
ans2 =0 
ans3 =0
for i in water:
    for j in sugar:
        if i+j<=f and j/i*100<=e:
            if j/(i+j) > ans3:
                ans1 = i+j 
                ans2 = j                   


print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d, e, f = map(int, input().split())
    max_weight = f // 100
    best_water = 0
    best_suger = 0
    best_density = 0
    is_ideal = False
    for water in range(a, max_weight + 1):
        max_a = water // a
        max_b = water // b
        is_exist = False

        for add_a in range(max_a):
            water_a = (add_a + 1) * a
            is_exist = water_a + (water - water_a) // b * b == water
            if is_exist:
                break

        if not is_exist:
            for add_b in range(max_b):
                water_b = (add_b + 1) * b
                is_exist = water_b + (water - water_b) // a * a == water
                if is_exist:
                    break

        if is_exist:
            max_suger = e * water
            remaining = min(f - water * 100, max_suger)
            max_c = remaining // c
            max_d = remaining // d

            for add_c in range(max_c):
                sugar_c = (add_c + 1) * c
                sugar = sugar_c + (remaining - sugar_c) // d * d
                density = sugar / (water + sugar)
                if density > best_density:
                    best_density = density
                    best_water = water
                    best_suger = sugar
                    is_ideal = sugar == max_suger
                    if is_ideal:
                        break

            if not is_ideal:
                for add_d in range(max_d):
                    sugar_d = (add_d + 1) * d
                    sugar = sugar_d + (remaining - sugar_d) // c * c
                    density = sugar / (water + sugar)
                    if density > best_density:
                        best_density = density
                        best_water = water
                        best_suger = sugar
                        is_ideal = sugar == max_suger
                        if is_ideal:
                            break
            if is_ideal:
                break

    print(f'{best_water * 100 + best_suger} {best_suger}')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d, e, f = map(int, input().split())
    max_weight = f // 100
    best_water = 0
    best_suger = 0
    best_density = 0
    ideal_density = e / (e + 100)
    for water in range(a, max_weight + 1):
        max_a = (water // a) * a
        max_b = (water // b) * b
        if water in [max_b + ((water - max_b) // a) * a, max_a + ((water - max_a) // b) * b]:
            remaining = min(f - water * 100, e * water)
            max_c = (remaining // c) * c
            max_d = (remaining // d) * d
            suger = max((max_c + (remaining - max_c) // d * d),
                        (max_d + (remaining - max_d) // c * c))
            density = suger / (water + suger)
            if density > best_density:
                best_density = density
                best_water = water
                best_suger = suger
                if best_density == ideal_density:
                    break
    print(f'{best_water * 100 + best_suger} {best_suger}')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d, e, f = map(int, input().split())
    max_weight = f // 100
    best_water = 0
    best_suger = 0
    best_density = 0
    ideal_density = e / (e + 100)
    for water in range(a, max_weight + 1):
        max_b = (water // b) * b
        if (water // a) * a == water or (max_b + (water - max_b) // a * a) == water:
            remaining = min(f - water * 100, e * water)
            max_d = (remaining // d) * d
            suger = max((remaining // c) * c,
                        (max_d + (remaining - max_d) // c * c))
            density = suger / (water + suger)
            if density > best_density:
                best_density = density
                best_water = water
                best_suger = suger
                if best_density == ideal_density:
                    break
    print(f'{best_water * 100 + best_suger} {best_suger}')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d, e, f = map(int, input().split())
    max_weight = f // 100
    best_water = 0
    best_suger = 0
    best_density = 0
    ideal_density = e / (e + 100)
    for water in range(a, max_weight):
        max_b = (water // b) * b
        if (water // a) * a == water or (max_b + (water - max_b) // a * a) == water:
            remaining = min((max_weight - water) * 100, e * water)
            max_d = (remaining // d) * d
            suger = max((remaining // c) * c,
                        (max_d + (remaining - max_d) // c * c))
            density = suger / (water + suger)
            if density > best_density:
                best_density = density
                best_water = water
                best_suger = suger
                # if best_density == ideal_density:
                #     break
    print(f'{best_water * 100 + best_suger} {best_suger}')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d, e, f = map(int, input().split())
    max_weight = int(f / 100)
    best_water = 0
    best_suger = 0
    best_density = 0
    ideal_density = e / (e + 100)
    for water in range(a, max_weight):
        max_b = (water // b) * b
        if (water // a) * a == water or (max_b + (water - max_b) // a * a) == water:
            remaining = min((max_weight - water) * 100, e * water)
            max_d = (remaining // d) * d
            suger = max((remaining // c) * c,
                        (max_d + (remaining - max_d) // c * c))
            density = suger / (water + suger)
            if density > best_density:
                best_density = density
                best_water = water
                best_suger = suger
                if best_density == ideal_density:
                    break
    print(f'{best_water * 100 + best_suger} {best_suger}')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range(((A*i+B*j)*E//C+1)):
            for l in range(((A*i+B*j)*E-C*k)//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if water == 0:
                    break
                if water+sugar <= F and sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if water == 0:
                    break
                if sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if i==j==0:
                    break
                if sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if i==j==0:
                    break
                if water+sugar <= F and sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(100*C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if i==j==0:
                    break
                if water+sugar <= F and sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            water = 100*A*i+100*B*j
            sugar = C*k+D*(((A*i+B*j)*E-C*k)//D)
            if water == 0:
                continue
            if water+sugar <= F and dens <= sugar/(sugar+water):
                    dens = sugar/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = min(A, B)*100
ans_sugar = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            water = 100*A*i+100*B*j
            sugar = C*k+D*(((A*i+B*j)*E-C*k)//D)
            if water == 0:
                continue
            if water+sugar <= F:
                if dens < sugar/(sugar+water):
                    dens = sugar/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
            else:
                ans_sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = min(A, B)*100
ans_sugar = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            water = 100*A*i+100*B*j
            sugar = C*k+D*(((A*i+B*j)*E-C*k)//D)
            if water == 0:
                continue
            if water+sugar <= F:
                if dens < sugar/(sugar+water):
                    dens = sugar/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            water = 100*A*i+100*B*j
            sugar = C*k+D*(((A*i+B*j)*E-C*k)//D)
            if water == 0:
                continue
            if water+sugar <= F:
                if dens < sugar/(sugar+water):
                    dens = sugar/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            water = 100*A*i+100*B*j
            sugar = C*k+D*(((A*i+B*j)*E-C*k)//D)
            if i==j==0:
                continue
            if water+sugar <= F:
                if dens<sugar/(sugar+water):
                    dens = sugar/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
            else:
                continue
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        for k in range(101):
            water = 100*A*i+100*B*j
            sugar = C*k+D*(((A*i+B*j)*E-C*k)//D)
            if i==j==0:
                continue
            if water+sugar <= F:
                if dens<sugar/(sugar+water):
                    dens = sugar/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
dens = 0
ans_water = 0
ans_sugar = 0
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
                sugar = C*k+D*l
                if i==j==0:
                    break
                if water+sugar <= F and sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = 0
sugar = 0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range(F//C+1):
            for l in range(F//D+1):
                water = 100*i+100*j
                sugar = k+l
                if water+sugar <= F and sugar <= E//100*water:
                    break
print(water+sugar, sugar)

Submission status: Wrong Answer

Solution code:
#
# abc074 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 10 20 15 200"""
        output = """110 10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 1 2 100 1000"""
        output = """200 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """17 19 22 26 55 2802"""
        output = """2634 934"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    N = 0
    W = 0
    S = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    w = A*i+B*j
                    s = C*k+D*l
                    if w == 0 or 100*w+s > F or s > w*E:
                        break
                    n = 100*s / (100*w+s)
                    if n > N:
                        N = n
                        W = 100*w+s
                        S = s
    print(f"{W} {S}")


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
#
# abc074 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 10 20 15 200"""
        output = """110 10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 1 2 100 1000"""
        output = """200 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """17 19 22 26 55 2802"""
        output = """2634 934"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    N = 0
    W = 0
    S = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    w = A*i+B*j
                    s = C*k+D*l
                    if w == 0 or s == 0 or 100*w+s > F or w*s > E:
                        break
                    n = 100*s / (100*w+s)
                    if n > N:
                        N = n
                        W = 100*w+s
                        S = s
    print(f"{W} {S}")


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
#
# abc074 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 10 20 15 200"""
        output = """110 10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 1 2 100 1000"""
        output = """200 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """17 19 22 26 55 2802"""
        output = """2634 934"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    w = 0
    s = 0
    while True:
        if w + B < F//100:
            w += B
        else:
            break
    while True:
        if w + A < F//100:
            w += A
        else:
            break
    while True:
        if 100*w + s <= F and s + D <= E*w:
            s += D
        else:
            break
    while True:
        if 100*w + s <= F and s + C <= E*w:
            s += C
        else:
            break
    print(f"{100*w+s} {s}")


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
#
# abc074 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 10 20 15 200"""
        output = """110 10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 1 2 100 1000"""
        output = """200 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """17 19 22 26 55 2802"""
        output = """2634 934"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    w = 0
    s = 0
    while w + B <= F//100:
        w += B
        while w + A <= F//100:
            w += A
            while 100*w + s <= F and s + D <= E*w:
                s += D
                while 100*w + s <= F and s + C <= E*w:
                    s += C
    print(f"{100*w+s} {s}")


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
def main():
	A, B, C, D, E, F = map(int, input().split())
	water = set()
	sugar = set()

	for i in range(F // (100 * A) + 1):
		for j in range(F // (100 * B) + 1):
			water_amount = 100 * A * i + 100 * B * j
			if 0 < water_amount and water_amount <= F:
				water.add(water_amount)

	for i in range(F // C + 1):
		for j in range(F // D + 1):
			sugar_amount = C * i + D * j
			if sugar_amount <= F:
				sugar.add(sugar_amount)

	# print(water)
	# print(sugar)

	max_c = 0
	max_w = 0
	max_s = 0

	for w in water:
		for s in sugar:
			if w + s > F:
				continue
			elif s / w > E / 100:
				continue
			elif s * 100 / (w + s) > max_c:
				max_c = s * 100 / (w + s)
				max_w = w
				max_s = s

	print(max_w + max_s, max_s)

 
if __name__ == "__main__":
  	main()

Submission status: Wrong Answer

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

#まず容器fグラムに入る分の砂糖の組み合わせを考える。
suger = []
for i in range(0, f+1):
    for j in range(0, f+1):
        tmp = c*i + d*j
        if (tmp <= f):
            suger.append(tmp)
suger = list(set(suger))

#次に容器fグラムに入る分の水の組み合わせを考える
watter = []
for i in range(0, f+1, 100):
    for j in range(0, f+1, 100):
        tmp = (a*i + b*j)
        if (tmp <= f):
            watter.append(tmp)

watter = list(set(watter))

#sugerとwatterの組み合わせを列挙して、条件を満たすもので濃度を列挙する
max_conset = 0.0
ans_watter = 0
ans_sugger = 0

#print(watter)
#print(suger)

for i in range(len(watter)):
    for j in range(len(suger)):

        if (0 < suger[j] + watter[i] <= f):
            if (watter[i] // 100 * e >= suger[j]):
                consent = 100 * suger[j] / (watter[i] + suger[j])
                if (max_conset < consent):
                    ans_watter = watter[i] + suger[j]
                    ans_sugger = suger[j]
                    max_conset = consent

print(ans_watter, ans_sugger)

Submission status: Wrong Answer

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

#まず容器fグラムに入る分の砂糖の組み合わせを考える。
suger = []
for i in range(0, f+1):
    for j in range(0, f+1):
        tmp = c*i + d*j
        if (tmp <= f):
            suger.append(tmp)
suger = list(set(suger))

#次に容器fグラムに入る分の水の組み合わせを考える
watter = []
for i in range(0, f//100):
    for j in range(0, f//100):
        tmp = 100*a*i + 100*b*j
        if (tmp <= f):
            watter.append(tmp)

watter = list(set(watter))

#sugerとwatterの組み合わせを列挙して、条件を満たすもので濃度を列挙する
max_conset = 0.0
ans_watter = 0
ans_sugger = 0

#print(watter)
#print(suger)

for i in range(len(watter)):
    for j in range(len(suger)):

        if (0 < suger[j] + watter[i] <= f):
            if (watter[i] // 100 * e >= suger[j]):
                consent = 100 * suger[j] / (watter[i] + suger[j])
                if (max_conset < consent):
                    ans_watter = watter[i] + suger[j]
                    ans_sugger = suger[j]
                    max_conset = consent

print(ans_watter, ans_sugger)