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 math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

A,B,C,D,E,F = LI()

"""
100gあたりEgとける

ABCDは何回でも行える
A,Bは100A, 100B

Fg以内で砂糖を溶け残らせてはいけない
水全体と砂糖の量を求める

濃度は100b/(a+b)

砂糖を細かく追加して、溶け残らないようにする？
2, 5あれば、4,5にできるので、組み合わせを全部試す？
ビーカー量が200gで、溶ける量が15gなら、最大でも30gまでしか溶けない
10, 20なら、10, 10, 10,と10, 20の組み合わせが考えられる
Cの最大回数とDの最大回数を求める
それぞれの量の組み合わせをすべて試す
例えば10回、10回なら、0,0/1,0/2,0...とすべて試す
"""
max_sugar_amount = int(F/(100+E)*E)
max_C_times = int(max_sugar_amount // C)
max_D_times = int(max_sugar_amount // D)
#  print('max sugar', max_sugar_amount, 'max c', max_C_times, 'max d', max_D_times)
#  exit()
ans_sugar = 0
ans_water = 0
ans_density = 0
def check_density(sugar, water, new_sugar, new_water):
    if water + sugar == 0:
        return True 
    density = (100*sugar) / (water+sugar)
    new_density = (100*new_sugar) / (new_water + new_sugar)
    return density < new_density


for i in range(1, max_C_times+1):
    #  print('i', i)
    if max_D_times == 0:
        sugar_amount = i*C
        if sugar_amount > max_sugar_amount:
            break
        else:
            # 溶け切る場合
            #  print('溶け切る')
            water_limit = F - sugar_amount
            min_water_amount = sugar_amount / E * 100
            #  print(sugar_amount, min_water_amount)
            max_A_times = int(water_limit // (A*100))
            max_B_times = int(water_limit // (B*100))
            #  print('maxA', max_A_times)
            for k in range(1, max_A_times+1):
                if max_B_times == 0:
                    # 水Bはいれられないとき
                    water = k*100*A
                    if water_limit >= water >= min_water_amount:
                        # 水の量が砂糖を溶かすのに十分 # 水量がこえていない
                        if check_density(ans_sugar, ans_water, sugar_amount, water):
                            ans_sugar = sugar_amount
                            ans_water = water
                else:
                    for l in range(0, max_B_times+1):
                        water = k*100*A + l*100*B
                        if water_limit >= water >= min_water_amount:
                            # 水の量が砂糖を溶かすのに十分
                            if check_density(ans_sugar, ans_water, sugar_amount, water):
                                ans_sugar = sugar_amount
                                ans_water = water

    for j in range(0, max_D_times+1):
        #  print(j)
        sugar_amount = i*C + j*D
        if sugar_amount > max_sugar_amount:
            break
        else:
            water_limit = F - sugar_amount
            min_water_amount = sugar_amount / E * 100
            max_A_times = int(water_limit // (A*100))
            max_B_times = int(water_limit // (B*100))
            for k in range(1, max_A_times+1):
                if max_B_times == 0:
                    water = k*100*A
                    if water_limit >= water >= min_water_amount:
                        # 水の量が砂糖を溶かすのに十分 # 水量がこえていない
                        if check_density(ans_sugar, ans_water, sugar_amount, water):
                            ans_sugar = sugar_amount
                            ans_water = water
                else:
                    for l in range(max_B_times+1):
                        water = k*100*A + l*100*B
                        if water_limit >= water >= min_water_amount:
                            if check_density(ans_sugar, ans_water, sugar_amount, water):
                                ans_sugar = sugar_amount
                                ans_water = water
print(ans_water + ans_sugar, ans_sugar)

Submission status: Wrong Answer

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

Water = A
Sugar = 0
Consent = 0

# 濃度計算
def calc(water, sugar):
    if water == 0 and sugar == 0:
        return 0
    return (100 * sugar) / (water + sugar) 

def dfs(water, sugar):
    global Water, Sugar, Consent

    if water + sugar > F:
        return 0
    if calc(water, sugar) > calc(100, E):
        return 0

    if Consent < calc(water, sugar):
        Consent = calc(water, sugar)
        Water = water
        Sugar = sugar

    dfs(water + A*100, sugar)
    dfs(water + B*100, sugar)
    dfs(water, sugar + C)
    dfs(water, sugar + D)

dfs(0,0)
print(Water+Sugar, Sugar)

Submission status: Wrong Answer

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

Water = 1
Sugar = 0
Consent = 0

# 濃度計算
def calc(water, sugar):
    if water == 0 and sugar == 0:
        return 0
    return (100 * sugar) / (water + sugar) 

def dfs(water, sugar):
    global Water, Sugar, Consent

    if water + sugar > F:
        return 0
    if calc(water, sugar) > calc(100, E):
        return 0

    if Consent < calc(water, sugar):
        Consent = calc(water, sugar)
        Water = water
        Sugar = sugar

    dfs(water + A*100, sugar)
    dfs(water + B*100, sugar)
    dfs(water, sugar + C)
    dfs(water, sugar + D)

dfs(0,0)
print(Water+Sugar, Sugar)

Submission status: Wrong Answer

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

Water = 0
Sugar = 0
Consent = 0

# 濃度計算
def calc(water, sugar):
    if water == 0 and sugar == 0:
        return 0
    return (100 * sugar) / (water + sugar) 

def dfs(water, sugar):
    global Water, Sugar, Consent

    if water + sugar > F:
        return 0
    if calc(water, sugar) > calc(100, E):
        return 0

    if Consent < calc(water, sugar):
        Consent = calc(water, sugar)
        Water = water
        Sugar = sugar

    dfs(water + A*100, sugar)
    dfs(water + B*100, sugar)
    dfs(water, sugar + C)
    dfs(water, sugar + D)

dfs(0,0)
print(Water+Sugar, Sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(31) for j in range(31)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)][1:]

res = [100, -1]
for w in water:
    for s in sugar:
        if w + s <= F and s <= w * E // 100:
            if s / (w + s) > res[1] / res[0]:
                res = [w + s, s]

print(" ".join(map(str, res)))

Submission status: Wrong Answer

Solution code:
# 2019/08/07

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

max_a=f//100*a
max_b=f//100*b
min_ab=min(a,b)*100
max_c=(f-min_ab)//c
max_d=(f-min_ab)//d


def solve():
    cnt=0   
    ans=0   
    for i in range(max_a):
        if i*a>f:break
        for j in range(max_b):
            if i==j==0:continue
            if (i*a+j*b)*100>f:break

            for k in range(max_c):
                if (i*a+j*b)*100+k*c>f:break
                for l in range(max_d):
                    if k==l==0:continue
                    if (i*a+j*b)*100+k*c+l*d>f:break
                    w=(i*a+j*b)*100
                    s=k*c+l*d
                    D=s/w
                    if D>e/100:break
                    if cnt<D:
                        ans=(w+s,s)
                        cnt=D
                    if D==e/100:
                        return ans
    return ans
ans=solve()
if ans==0:print(0,0)
else:print(*ans)

Submission status: Wrong Answer

Solution code:
import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    L = []
    for i in range(31):
        for j in range(31):
            if 100*(A*i+B*j) <= F:
                L.append(100*(A*i+B*j))
    L.sort()

    mx = 0
    ans = (A*100, 0)
    for l in L:
        ll = l // 100 * E
        x = 0
        for i in range(ll//C+1):
            for j in range(ll//D+1):
                if C*i+D*j<=ll and l+C*i+D*j<=F:
                    x = max(x, C*i+D*j)
        if mx < x:
            mx = x
            ans = (l, mx)
    print(ans[0]+ans[1], ans[1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    L = []
    for i in range(31):
        for j in range(31):
            if 100*(A*i+B*j) <= F:
                L.append(100*(A*i+B*j))
    L.sort()

    mx = 0
    ans = (A, 0)
    for l in L:
        ll = l // 100 * E
        x = 0
        for i in range(ll//C+1):
            for j in range(ll//D+1):
                if C*i+D*j<=ll and l+C*i+D*j<=F:
                    x = max(x, C*i+D*j)
        if mx < x:
            mx = x
            ans = (l, mx)
    print(ans[0]+ans[1], ans[1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    L = []
    for i in range(31):
        for j in range(31):
            if 100*(A*i+B*j) <= F:
                L.append(100*(A*i+B*j))
    L.sort()

    mx = 0
    ans = (0, 0)
    for l in L:
        ll = l // 100 * E
        x = 0
        for i in range(ll//C+1):
            for j in range(ll//D+1):
                if C*i+D*j<=ll and l+C*i+D*j<=F:
                    x = max(x, C*i+D*j)
        if mx < x:
            mx = x
            ans = (l, mx)
    print(ans[0]+ans[1], ans[1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
a,b,c,d,e,f = list(map(int,input().split()))
#水の入れ方を列挙
total_water_set = set()
for hund_a in range(0, f+1, 100*a):
    total_water = hund_a
    while total_water <= f:
        total_water_set.add(total_water)
        total_water += 100*b

total_water_set.remove(0)
#砂糖の入れ方を列挙
total_sugar_set = set()
for _c in range(0, f+1, c):
    total_sugar = _c
    while total_sugar <= f:
        total_sugar_set.add(total_sugar)
        total_sugar += d

max_nodo = 0
max_sugawater_weight = 0
max_sugar_weight = 0
import decimal
total_water_set = list(map(decimal.Decimal,total_water_set))
total_sugar_set = list(map(decimal.Decimal,total_sugar_set))
nodo_limit = 100 * decimal.Decimal(e) / (100+decimal.Decimal(e))
for water in total_water_set:
    for sugar in total_sugar_set:
        if water + sugar <= f:
            nodo = 100 * sugar / (water + sugar)
            if nodo > max_nodo and nodo <= nodo_limit:
                max_nodo = nodo
                max_sugawater_weight = water + sugar
                max_sugar_weight = sugar
print("{} {}".format(max_sugawater_weight,max_sugar_weight))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int, C: int, D: int, E: int, F: int):

    mwater = 0
    msugar = 0
    mnoudo = 0

    # ope1
    for i in range(-(-F//100)*A+1):
        # ope2
        for j in range(-(-F//100)*B + 1):
            water = 100*A*i+100*B*j
            if water > F:
                break
            # ope3
            for k in range(-(-water*E//100)//C + 1):
                if water+C*k > F:
                    break
                for l in range(-(-water*E//100)//D + 1):
                    sugar = C*k + D*l
                    if water + sugar > F:
                        break
                    if (water*E/100) < sugar:
                        break
                    if water+sugar == 0:
                        break
                    noudo = 100*sugar/(water+sugar)
                    # print(water, sugar, noudo)
                    if mnoudo < noudo:
                        mnoudo = noudo
                        mwater = water
                        msugar = sugar
    print(mwater+msugar, msugar)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int, C: int, D: int, E: int, F: int):

    mwater = 0
    msugar = 0
    mnoudo = 0

    # ope1
    for i in range(F//100*A + 1):
        # ope2
        for j in range(F//100*B + 1):
            water = 100*A*i+100*B*j
            if water > F:
                break
            # ope3
            for k in range((water*E//100)//C + 1):
                if water+C*k > F:
                    break
                for l in range((water*E//100)//D + 1):
                    sugar = C*k + D*l
                    if water + sugar > F:
                        break
                    if (water*E/100) < sugar:
                        break
                    if water+sugar == 0:
                        break
                    noudo = 100*sugar/(water+sugar)
                    # print(water, sugar, noudo)
                    if mnoudo < noudo:
                        mnoudo = noudo
                        mwater = water
                        msugar = sugar
    print(mwater+msugar, msugar)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

amax = F//(100*A)
bmax = F//(100*B)

concmx =0
wholemx =0
sugarmx =0

for a in range(amax,-1,-1):
    for b in range(bmax,-1,-1):
        cmax = (F-100*A*a-100*B*b)//C
        dmax = (F-100*A*a-100*B*b)//D
        for c in range(cmax,-1,-1):
            for d in range(dmax,-1,-1):
                sugar =C*c+D*d
                whole = 100*A*a+100*B*b+sugar
                if whole ==0:
                    break
                elif sugar/whole <= E/(100+E) and whole <=F:
                    if sugar/whole > concmx:
                        concmx =sugar/whole
                        sugarmx = sugar
                        wholemx =whole
                    
                   
print(str(wholemx)+" "+str(sugarmx))

Submission status: Wrong Answer

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

ans = 0
sugar = 0
sugar_water = 0
for a in range(F // (A * 100) + 1):
    for b in range((F - 100 * A * a) // (B * 100) + 1):
        for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
            for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                x = a * A + b * B
                y = c * C + d * D
                if x == 0:
                    continue
                if x * E >= y and ans < (100 * y)/(x*100+y):
                    ans = (100 * y)/(x*100+y)
                    sugar = y
                    sugar_water = 100 * x + y
print(sugar_water,sugar)

Submission status: Wrong Answer

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

ans = 0
sugar = 0
sugar_water = 0
for a in range(F // (A * 100) + 1):
    for b in range((F - 100 * A * a) // (B * 100) + 1):
        for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
            for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                x = a * A + b * B
                y = c * C + d * D
                if x*100+y == 0:
                    continue
                if x * E >= y and ans < (100 * y)/(x*100+y):
                    ans = (100 * y)/(x*100+y)
                    sugar = y
                    sugar_water = 100 * x + y
print(sugar_water,sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
sugar = 0
s_water = 100
for a in range(F//(100*A)+1):
  for b in range((F-100*A*a)//(100*B)+1):
    if a == 0 and b == 0:
      continue
    f = F - 100*(A*a+B*b)
    max_s = min((A*a+B*b)*E, f)
    for c in range(max_s//C+1):
      d = (max_s-c*C)//D
      sugar_temp = c*C+d*D
      s_water_temp = 100*(A*a+B*b) + sugar_temp
      if sugar_temp/s_water_temp > sugar/s_water:
        sugar = sugar_temp
        s_water = s_water_temp
print(s_water, sugar)

Submission status: Wrong Answer

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

A=sorted(list(set([a*i+b*j for j in range(f//(100*b)+1) for i in range(f//(100*a)+1) if 100*(a*i+b*j)<=f])))
B=sorted(list(set([c*i+d*j for j in range(f//d+1) for i in range(f//c+1) if c*i+d*j<=f])))

r=w=s=0
for x in A:
    i=0
    while x*100+B[i]<=f and B[i]<=x*e:i+=1
    if x!=0 or i>1:
        if r<B[max(0,i-1)]/(x*100+B[max(0,i-1)]):
            w=x*100+B[max(0,i-1)]
            s=B[max(0,i-1)]
            r=s/w
print(w,s)

Submission status: Wrong Answer

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

for i in range(F//100//A+1):
  WA = i*100*A
  for k in range((F-WA)//100//B+1):
    WB = k*100*B
    W = WA+WB
    if W <= F:
      for j in range((F-W)//C+1):
        SC = j*C
        for l in range((F-W-C)//D+1):
          SD = l*D
          S = SC+SD
          if 0 < W+S <= F and S <= W*E/100:
            Conc = S/(S+W)
            if Conc > Concmax:
              Concmax= Conc
              Sans = S
              M = S+W
#              print(WA,WB,SC,SD,Conc)
print(M,Sans)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
conc = 0
total = 0
sugar = 0
if c <= e*(f-c)//(100*a):
    for i in range((f-100*a)//d + 1):
        for j in range((f-100*a-d*i)//c + 1):
            sugar_total = d*i + c*j
            conc_prep = sugar_total/(sugar_total+100*a)
            if not sugar_total > e*a:
                if conc < conc_prep:
                    conc = conc_prep
                    total = sugar_total + 100*a
                    sugar = sugar_total

    for i in range(1, f//(100*b)+1):
        diff = f - 100*b*i
        for j in range(diff//(100*a)+1):
            sugar_max = diff - 100*a*j
            for k in range(sugar_max//d + 1):
                for l in range((sugar_max - k*d)//c + 1):
                    sugar_total = k*d + l*c
                    if not sugar_total > e*(b*i+a*j):
                        total_prep = sugar_total + 100*(b*i + a*j)
                        conc_prep = sugar_total/total_prep
                        if conc < conc_prep:
                            conc = conc_prep
                            total = total_prep
                            sugar = sugar_total
print(total, sugar)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
conc = 0
total = 0
sugar = 0
if c <= e*(f-c)//100:
    for i in range((f-100*a)//d + 1):
        for j in range((f-100*a-d*i)//c + 1):
            sugar_total = d*i + c*j
            conc_prep = sugar_total/(sugar_total+100*a)
            if not sugar_total > e*a:
                if conc < conc_prep:
                    conc = conc_prep
                    total = sugar_total + 100*a
                    sugar = sugar_total

    for i in range(1, f//(100*b)+1):
        diff = f - 100*b*i
        for j in range(diff//(100*a)+1):
            sugar_max = diff - 100*a*j
            for k in range(sugar_max//d + 1):
                for l in range((sugar_max - k*d)//c + 1):
                    sugar_total = k*d + l*c
                    if not sugar_total > e*(b*i+a*j):
                        total_prep = sugar_total + 100*(b*i + a*j)
                        conc_prep = sugar_total/total_prep
                        if conc < conc_prep:
                            conc = conc_prep
                            total = total_prep
                            sugar = sugar_total
print(total, sugar)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
conc = 0
total = 0
sugar = 0
if c <= e*f//100:
    for i in range((f-100*a)//d + 1):
        for j in range((f-100*a-d*i)//c + 1):
            sugar_total = d*i + c*j
            conc_prep = sugar_total/(sugar_total+100*a)
            if not sugar_total > e*a:
                if conc < conc_prep:
                    conc = conc_prep
                    total = sugar_total + 100*a
                    sugar = sugar_total

    for i in range(1, f//(100*b)+1):
        diff = f - 100*b*i
        for j in range(diff//(100*a)+1):
            sugar_max = diff - 100*a*j
            for k in range(sugar_max//d + 1):
                for l in range((sugar_max - k*d)//c + 1):
                    sugar_total = k*d + l*c
                    if not sugar_total > e*(b*i+a*j):
                        total_prep = sugar_total + 100*(b*i + a*j)
                        conc_prep = sugar_total/total_prep
                        if conc < conc_prep:
                            conc = conc_prep
                            total = total_prep
                            sugar = sugar_total
print(total, sugar)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
conc = 0
total = 0
sugar = 0
if c <= e*a:
    for i in range((f-100*a)//d + 1):
        for j in range((f-100*a-d*i)//c + 1):
            sugar_total = d*i + c*j
            conc_prep = sugar_total/(sugar_total+100*a)
            if not sugar_total > e*a:
                if conc < conc_prep:
                    conc = conc_prep
                    total = sugar_total + 100*a
                    sugar = sugar_total

    for i in range(1, f//(100*b)+1):
        diff = f - 100*b*i
        for j in range(diff//(100*a)+1):
            sugar_max = diff - 100*a*j
            for k in range(sugar_max//d + 1):
                for l in range((sugar_max - k*d)//c + 1):
                    sugar_total = k*d + l*c
                    if not sugar_total > e*(b*i+a*j):
                        total_prep = sugar_total + 100*(b*i + a*j)
                        conc_prep = sugar_total/total_prep
                        if conc < conc_prep:
                            conc = conc_prep
                            total = total_prep
                            sugar = sugar_total
print(total, sugar)

Submission status: Wrong Answer

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

for i in range((f-100*a)//d + 1):
    for j in range((f-100*a-d*i)//c + 1):
        sugar_total = d*i + c*j
        conc_prep = sugar_total/(sugar_total+100*a)
        if not sugar_total > e*a:
            if conc < conc_prep:
                conc = conc_prep
                total = sugar_total + 100*a
                sugar = sugar_total

for i in range(1, f//(100*b)+1):
    diff = f - 100*b*i
    for j in range(diff//(100*a)+1):
        sugar_max = diff - 100*a*j
        for k in range(sugar_max//d + 1):
            for l in range((sugar_max - k*d)//c + 1):
                sugar_total = k*d + l*c
                if not sugar_total > e*(b*i+a*j):
                    total_prep = sugar_total + 100*(b*i + a*j)
                    conc_prep = sugar_total/total_prep
                    if conc < conc_prep:
                        conc = conc_prep
                        total = total_prep
                        sugar = sugar_total
print(total, sugar)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
wans,sans=100*a,0
Cans=0
for p in range(1+(f//100*a)):
    for q in range(1+(f//100*b)):
        water=100*(a*p+b*q)
        smax=e*(a*p+b*q)
        if water>f or water==0:
            pass
        else:
            for r in range(1+(smax//c)):
                smax-=c*r
                for s in range(1+(smax//d)):
                    suger=c*r+d*s
                    C=(100*suger)/(suger+water)
                    if water+suger>f:
                        pass
                    else:
                        if C>=Cans:
                            wans,sans=water,suger
                            Cans=C
print(wans+sans,sans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
salt = 0
ans = [0,0]
for i in range(31):
  for j in range(31):
    k = 100*(a*i+b*j)
    l = c*i+d*j
    if 0<k+l<=f and salt<100*l/(k+l) and 100*l >= k:
      ans[0] = k+l
      ans[1] = l
      salt = 100*l / (k+l)
print(ans[0], ans[1])

Submission status: Wrong Answer

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

L = []
for a in range(31):
    for b in range(31):
        k = A*a+B*b
        if 0 < 100*k <= F:
            L.append(k)

L.sort()

lim = 0
for l in L:
    limit = min(F-100*l, E*l)
    if limit > lim:
        lim = limit
        w = 100*l

su = 0
for c in range(3000):
    if C*c >lim:
        break
    d = (lim - C*c) // D
    p = C*c+D*d
    if p > su:
        su = p
print(w+su, su)

Submission status: Wrong Answer

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

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

sugar = []
for i in range(C+1):
    for j in range(D+1):
        if C*i + D*j < F:
            sugar.append(C*i+D*j)
            
water.sort()
sugar.sort()
    
MAX = 0
MAXSUGAR = 0
MAXWEIGHT = 0
tmpsugar = 0
for i in range(len(water)):
    for j in range(len(sugar)):
        tmpsugar = sugar[j]
        if tmpsugar == 0:
            MAXWEIGHT = max(MAXWEIGHT,water[i])
            continue
        while (water[i]+tmpsugar)<=F and tmpsugar <= water[i]*E//100:
            if MAX  <= 100*tmpsugar/(water[i]+tmpsugar):
                MAX  = 100*tmpsugar/(water[i]+tmpsugar)
                MAXSUGAR = tmpsugar
                MAXWEIGHT = water[i]+tmpsugar
            tmpsugar += sugar[j]

print(str(MAXWEIGHT)+" "+str(MAXSUGAR))

Submission status: Wrong Answer

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

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

sugar = []
for i in range(C+1):
    for j in range(D+1):
        if C*i + D*j < F:
            sugar.append(C*i+D*j)
            
water.sort()
sugar.sort()
    
MAX = 0
MAXSUGAR = 0
MAXWEIGHT = 0
tmpsugar = 0
for i in range(len(water)):
    for j in range(len(sugar)):
        tmpsugar = sugar[j]
        if tmpsugar == 0:
            continue
        while (water[i]+tmpsugar)<=F and tmpsugar <= water[i]*E//100:
            if MAX  <= 100*tmpsugar/(water[i]+tmpsugar):
                MAX  = 100*tmpsugar/(water[i]+tmpsugar)
                MAXSUGAR = tmpsugar
                MAXWEIGHT = water[i]+tmpsugar
            tmpsugar += sugar[j]

print(str(MAXWEIGHT)+" "+str(MAXSUGAR))