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
water1,water2,sugar1,sugar2,per_limit,total_limit = map(int,input().split())

max_sugar_per_water = 0
best_total = 0
best_sugar = 0
# waterはfor使うか、、、

if per_limit == 0:
    print(100*water1)
    sys.exit()

for time_water1 in range(30):
    for time_water2 in range(30):
        water = water1*time_water1*100 + water2*time_water2*100
        if water > total_limit:
            break
        if water == 0:
            continue

        sugar_limit = (water//100)*per_limit
        time_sugar1 = 0
        while True:
            time_sugar2 = 0
            while True:
                sugar = sugar1*time_sugar1+sugar2*time_sugar2

                # トータルの重さ判定
                if total_limit < water+sugar:
                    break
                # 溶ける量制限判定
                if sugar_limit < sugar:
                    break

                # 濃度求めて、最大なら更新
                sugar_per_water = sugar/water
                if sugar_per_water > max_sugar_per_water:
                    max_sugar_per_water = sugar_per_water
                    best_sugar = sugar
                    best_total = sugar+water
                time_sugar2 += 1
            if sugar1*time_sugar1 > sugar_limit or sugar1*time_sugar1 + water > total_limit:
                break
            time_sugar1 += 1
        if water > total_limit:
            break
print(best_total,best_sugar)

Submission status: Wrong Answer

Solution code:
water1,water2,sugar1,sugar2,per_limit,total_limit = map(int,input().split())

max_sugar_per_water = 0
best_total = 0
best_sugar = 0
# waterはfor使うか、、、
for time_water1 in range(30):
    for time_water2 in range(30):
        water = water1*time_water1*100 + water2*time_water2*100
        if water > total_limit:
            break
        if water == 0:
            continue

        sugar_limit = (water//100)*per_limit
        time_sugar1 = 0
        while True:
            time_sugar2 = 0
            while True:
                sugar = sugar1*time_sugar1+sugar2*time_sugar2

                # トータルの重さ判定
                if total_limit < water+sugar:
                    break
                # 溶ける量制限判定
                if sugar_limit < sugar:
                    break

                # 濃度求めて、最大なら更新
                sugar_per_water = sugar/water
                if sugar_per_water > max_sugar_per_water:
                    max_sugar_per_water = sugar_per_water
                    best_sugar = sugar
                    best_total = sugar+water
                time_sugar2 += 1
            if sugar1*time_sugar1 > sugar_limit or sugar1*time_sugar1 + water > total_limit:
                break
            time_sugar1 += 1
        if water > total_limit:
            break
print(best_total,best_sugar)

Submission status: Wrong Answer

Solution code:
water1,water2,sugar1,sugar2,per_limit,total_limit = map(int,input().split())

max_sugar_per_water = 0
best_total = 0
best_sugar = 0
# waterはfor使うか、、、
for time_water1 in range(30):
    for time_water2 in range(30):
        water = water1*time_water1*100 + water2*time_water2*100
        if water > total_limit:
            break
        if water == 0:
            continue

        sugar_limit = (water//100)*per_limit
        time_sugar1 = 0
        while True:
            time_sugar2 = 0
            while True:
                sugar = sugar1*time_sugar1+sugar2*time_sugar2

                # トータルの重さ判定
                if total_limit < water+sugar:
                    break
                # 溶ける量制限判定
                if sugar_limit < sugar:
                    break

                # 濃度求めて、最大なら更新
                sugar_per_water = sugar/water
                if sugar_per_water > max_sugar_per_water:
                    max_sugar_per_water = sugar_per_water
                    best_sugar = sugar
                    best_total = sugar+water
                time_sugar2 += 1

            if total_limit < water+sugar:
                break
            time_sugar1 += 1
        if water > total_limit:
            break
print(best_total,best_sugar)

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy

def solve():
    a, b, c, d, e, f = getList()
    dp = [[0 for i in range(f+1)] for j in range(f+1)]
    dp[0][0] = 1
    for i in range(f):
        for j in range(f):
            if dp[i][j] == 1:
                if i + a * 100 <= f:
                    dp[i+a*100][j] = 1
                if i + b * 100 <= f:
                    dp[i+b*100][j] = 1
                if i + c <= f:
                    dp[i+c][j+c] = 1
                if i + d <= f:
                    dp[i+d][j+d] = 1

    ans = (a, 0)

    for i in range(1, f+1):
        for j in range(f+1):
            if dp[i][j] == 1:
                if e * (i-j) / 100 >= j:
                    if ans[1]/ans[0] < j/i:
                        ans = (i, j)


    print(*ans)





def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy

def solve():
    a, b, c, d, e, f = getList()
    dp = [[0 for i in range(f+1)] for j in range(f+1)]
    dp[0][0] = 1
    for i in range(f):
        for j in range(f):
            if dp[i][j] == 1:
                if i + a * 100 <= f:
                    dp[i+a*100][j] = 1
                if i + b * 100 <= f:
                    dp[i+b*100][j] = 1
                if i + c <= f:
                    dp[i+c][j+c] = 1
                if i + d <= f:
                    dp[i+d][j+d] = 1

    ans = (1, 0)

    for i in range(1, f+1):
        for j in range(f+1):
            if dp[i][j] == 1:
                if e * (i-j) / 100 >= j:
                    if ans[1]/ans[0] < j/i:
                        ans = (i, j)


    print(*ans)





def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Submission status: Wrong Answer

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

sugar_water = 0
sugar = 0
conc = 0
for i in range(F//(100*A) + 1):
    for j in range((F - 100*A*i)//(100*B) + 1):
        if i == 0 and j == 0:
            continue
        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):
                if conc < (C*k + D*l)/(100*A*i + 100*B*j + C*k + D*l) <= E/(100 + E):
                    conc = (C*k + D*l)/(100*A*i + 100*B*j + C*k + D*l)
                    sugar_water = 100*A*i + 100*B*j + C*k + D*l
                    sugar = C*k + D*l

print(sugar_water, end=' ')

print(sugar)

Submission status: Wrong Answer

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

sugar_water = 0
sugar = 0
conc = 0
for i in range(F//(100*A) + 1):
    for j in range((F - 100*A*i)//(100*B) + 1):
        if i == 0 and j == 0:
            continue
        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):
                if conc < (C*k + D*l)/(100*A*i + 100*B*j + C*k + D*l) <= E/100:
                    conc = (C*k + D*l)/(100*A*i + 100*B*j + C*k + D*l)
                    sugar_water = 100*A*i + 100*B*j + C*k + D*l
                    sugar = C*k + D*l

print(sugar_water, end=' ')

print(sugar)

Submission status: Wrong Answer

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

sugar_water = 0
sugar = 0
conc = 0
for i in range(F//(100*A) + 1):
    for j in range((F//100 - A*i) // B + 1):
        if i == 0 and j == 0:
            continue
        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):
                if conc < (C*k + D*l)/(100*A*i + 100*B*j) <= E/100:
                    conc = (C*k + D*l)/(100*A*i + 100*B*j)
                    sugar_water = 100*A*i + 100*B*j + C*k + D*l
                    sugar = C*k + D*l

print(sugar_water, end=' ')
print(sugar)

Submission status: Wrong Answer

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

x, y = a, 0
conc_best = 0
for i in range(f//a+1):
    for j in range(f//b+1):
        if i == 0 and j == 0:
            continue
        wat = a*i + b*j
        rest = f - wat
        sug_max = wat * e // 100
        for k in range(rest//c+1):
            for l in range(rest//d+1):
                sug = c*k + d*l
                conc = sug / (sug+wat) * 100 
                if 0 <= sug <= sug_max and conc > conc_best:
                        x, y = (sug+wat), sug
print(x, y)

Submission status: Wrong Answer

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

wat = 0
wat_list = []
for i in range(f//a+1):
    for j in range(f//b+1):
        wat = a*i+b*j
        if 0 < wat <= f:
            wat_list.append(wat)

sug = 0
conc = 0
sug_max = 0 
conc_best = 0
sug_best = 0 
sug_wat_best = 0

for k in wat_list:
    sug_max = k//100 * e
    for l in range(sug_max // c + 1):
        for m in range(sug_max //d + 1):
            sug = c*l+d*m
            conc = sug/(sug+k)*100
            if 0<= sug <= sug_max and k+sug <= f and conc_best < conc :
                conc_best = conc
                sug_wat_best = sug + k
                sug_best = sug
print(sug_wat_best, sug_best)

Submission status: Wrong Answer

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

wat = 0
wat_list = []
for i in range(f//a+1):
    for j in range(f//b+1):
        wat = a*i+b*j
        if 0 < wat <= f:
            wat_list.append(wat)
print(wat_list)

sug = 0
conc = 0
sug_max = 0 
conc_best = 0
sug_best = 0 
sug_wat_best = 0

for k in wat_list:
    sug_max = k//100 * e
    for l in range(sug_max // c + 1):
        for m in range(sug_max //d + 1):
            sug = c*l+d*m
            conc = sug/(sug+k)*100
            if 0<= sug <= sug_max and k+sug <= f and conc_best < conc :
                conc_best = conc
                sug_wat_best = sug + k
                sug_best = sug
print(sug_wat_best, sug_best)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c, d, e, f = LI()

x = f // (100*a)
y = f // (100*b)

max_ = -1
max__ = 1
for i in range(x + 1):
    for j in range(y + 1):
        E = min((a*i + b*j) * e, f - (100*a*i + 100*b*j))
        E -= E % c % d
        if max_ * (a*i + b*j) < E * max__:
            max_ = E
            max__ = a*i + b*j

            ans1 = (a*i + b*j) * 100 + E
            ans2 = E
print(ans1, ans2)

Submission status: Wrong Answer

Solution code:
import sys

a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
thr = e / (e + 100) * 100

water = set()
sugar = set()

for i in range(f // a + 1):
    for j in range((f - i * a) // b + 1):
        if i + j >= 1:
            water.add(i * a + j * b)

for i in range(f // c + 1):
    for j in range((f - i * c) // d + 1):
        if i + j >= 1:
            sugar.add(i * c + j * d)

water = list(water)
sugar = list(sugar)
water.sort()
sugar.sort()

result = []
for w in water:
    for s in sugar:
        dens = s / (w + s) * 100
        if w + s > f or dens > thr:
            continue
        else:
            result.append((dens, w + s, s))

if len(result) == 0:
    print(-1)
    sys.exit()
else:
    result.sort(reverse=True)
    print(result[0][1], result[0][2])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
a = 0
x = 1
y = 0
for n in range(30):
    for m in range(30):
        if n*100*A+m*100*B>F:continue
        c = (n*A+m*B)*E
        d = F-100*(n*A+m*B)
        for k in range(min(c,d)+1):
            for l in range(min(c,d)+1):
                if k*C+l*D>(n*A+m*B)*E or n*100*A+m*100*B+k*C+l*D>F:continue
                if x*(k*C+l*D)>y*(n*100*A+m*100*B+k*C+l*D):
                    x = n*100*A+m*100*B+k*C+l*D
                    y = k*C+l*D
                    a = y/x
print(x,y)

Submission status: Wrong Answer

Solution code:
import sys

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

water = set()
sugar = set()

for i in range(f // a + 1):
    for j in range((f - i * a) // b + 1):
        if i + j >= 1:
            water.add(i * a + j * b)

for i in range(f // c + 1):
    for j in range((f - i * c) // d + 1):
        if i + j >= 1:
            sugar.add(i * c + j * d)

water = list(water)
sugar = list(sugar)
water.sort()
sugar.sort()

result = []
for w in water:
    for s in sugar:
        whole = w + s
        dens = s / w * 100
        if whole > f or dens > e:
            continue
        else:
            result.append((dens, whole, s))

if len(result) == 0:
    print(-1)
    sys.exit()
else:
    result.sort(reverse=True)
    print(result[0][1], result[0][2])

Submission status: Wrong Answer

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

i = 0
while True:
    j = 0
    if 100*a*i + 100*b*j > f:
        break
    while True:
        if 100*a*i + 100*b*j <= f:
            water.add(100*a*i + 100*b*j)
        else:
            break
        j += 1
    i += 1

i = 0
while True:
    j = 0
    if c*i + d*j > f:
        break
    while True:
        if c*i + d*j <= f:
            sugar.add(c*i + d*j)
        else:
            break
        j += 1
    i += 1

# print(water, sugar)
nodo = 0.0
ans = [0, 0]
for w in water:
    for s in sugar:
        if not w == 0 and f >= s+w:
            if e/100 >= s/w:
                if nodo < s/w:
                    nodo = s/w
                    ans = s+w, s

print(*ans)

Submission status: Wrong Answer

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

i = 0
while True:
    j = 0
    if 100*a*i + 100*b*j > f:
        break
    while True:
        if 100*a*i + 100*b*j <= f:
            water.add(100*a*i + 100*b*j)
        else:
            break
        j += 1
    i += 1

i = 0
while True:
    j = 0
    if c*i + d*j > f:
        break
    while True:
        if c*i + d*j <= f:
            sugar.add(c*i + d*j)
        else:
            break
        j += 1
    i += 1

# print(water, sugar)
nodo = 0.0
ans = []
for w in water:
    for s in sugar:
        if not w == 0 and f >= s+w:
            if e/100 >= s/w:
                if nodo < s/w:
                    nodo = s/w
                    ans = s+w, s

print(*ans)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
a = 0
x = 0
y = 0
for n in range(30):
    for m in range(30):
        if n*100*A+m*100*B>F:continue
        c = (n*A+m*B)*E
        d = F-100*(n*A+m*B)
        for k in range(min(c,d)+1):
            for l in range(min(c,d)+1):
                if k*C+l*D>(n*A+m*B)*E or n*100*A+m*100*B+k*C+l*D>F:continue
                if (k*C+l*D)>a*(n*100*A+m*100*B+k*C+l*D):
                    x = n*100*A+m*100*B+k*C+l*D
                    y = k*C+l*D
                    a = y/x
print(x,y)

Submission status: Wrong Answer

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

i = 0
while True:
    j = 0
    if 100*a*i + 100*b*j > f:
        break
    while True:
        if 100*a*i + 100*b*j <= f:
            water.add(100*a*i + 100*b*j)
        else:
            break
        j += 1
    i += 1

i = 0
while True:
    j = 0
    if c*i + d*j > f:
        break
    while True:
        if c*i + d*j <= f:
            sugar.add(c*i + d*j)
        else:
            break
        j += 1
    i += 1

# print(water, sugar)
nodo = 0.0
ans = []
for w in water:
    for s in sugar:
        if not w == 0 and f >= s+w:
            if e/100 >= s/w:
                if nodo < s/(s+w):
                    nodo = s/(s+w)
                    ans = s+w, s

print(*ans)

Submission status: Wrong Answer

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

i = 0
while True:
    j = 0
    if 100*a*i + 100*b*j > f:
        break
    while True:
        if 100*a*i + 100*b*j <= f:
            water.add(100*a*i + 100*b*j)
        else:
            break
        j += 1
    i += 1

i = 0
while True:
    j = 0
    if c*i + d*j > f:
        break
    while True:
        if c*i + d*j <= f:
            sugar.add(c*i + d*j)
        else:
            break
        j += 1
    i += 1

# print(water, sugar)
nodo = 0.0
ans = []
for w in water:
    for s in sugar:
        if not (s == 0 and w == 0) and f >= s+w:
            if e/100 >= s/(s+w):
                if nodo < s/(s+w):
                    nodo = s/(s+w)
                    ans = s+w, s

print(*ans)

Submission status: Wrong Answer

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

ans = []
noudo = 0

for a in range(A+1):
    for b in range(B+1):
        if a==0 and b==0:
            continue
        if F < 100*a+100*b:
            continue
        for c in range(3001):
            for d in range(3001):
                if c==0 and d==0:
                    continue
                if F < 100*a+100*b+c*C+d*D:
                    continue

                if c*C+d*D <= (a+b)*E:
                    if noudo < int(10000*(c*C+d*D)/(100*a+100*b+c*C+d*D)):
                        noudo = int(10000*(c*C+d*D)/(100*a+100*b+c*C+d*D))
                        ans = [100*a+100*b+c*C+d*D, c*C+d*D]
print(*ans)

Submission status: Wrong Answer

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

ans = []
noudo = 0

for a in range(A+1):
    for b in range(B+1):
        if a==0 and b==0:
            continue
        if F < 100*a+100*b:
            continue
        for c in range(3001):
            for d in range(3001):
                if c==0 and d==0:
                    continue
                if F < 100*a+100*b+c*C+d*D:
                    continue

                if c*C+d*D <= (a+b)*E:
                    if noudo < int(10000*(c*C+d*D)/(100*a+100*b+c*C+d*D)):
                        noudo = int(10000*(c*C+d*D)/(100*a+100*b+c*C+d*D))
                        ans = [100*a+100*b+c*C+d*D, c*C+d*D]
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
res = 0
ans = []

for x in range(F//(100*A)+1):
    for y in range((F-100*A*x)//(100*B)+1):
        if x == y == 0: continue
        sugarMAX = (A*x+B*y)*E
        M = F-100*A*x-100*B*y
        water = 100*A*x+100*B*y
        for z in range(M//C+1):
            for w in range((M-C*z)//D+1):
                sugar = C*z+D*w
                if sugar <= sugarMAX:
                    tmp = (sugar*100)/(sugar+water)
                    if tmp > res:
                        res = tmp
                        ans = [sugar+water, sugar]
                else:
                    break
print(*ans)

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 0 <= ok < len(s) and 100 * s[ok] / (i + s[ok]) > c:
            ans = [i, s[ok]]
            c = 100 * s[ok] / (i + s[ok])

    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 s[m] + 100 * i <= F:
                ok = m
            else:
                ng = m
        if ok >= 0 and 100 * s[ok] / (i + s[ok]) > c:
            ans = [i, s[ok]]
            c = 100 * s[ok] / (i + s[ok])

    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 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()