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:
a, b, c, d, e, f = map(int, input().split())

w = {0}
s = {0}

for i in range(f+1):
    for j in range(f+1):
        x = 100 * (a * i + b * j)
        if x <= f:
            w.add(x)

for i in range(f+1):
    for j in range(f+1):
        y = c * i + d * j
        if y <= f:
            s.add(y)

s_list = list(s)
s_list.sort()
w_list = list(w)
w_list.sort()


c_ans = 0
s_ans = 0
w_ans = 0

for i in range(1, len(w_list)):
    for j in range(1, len(s_list)):
        z = int(100 * s_list[j] / (s_list[j] + w_list[i]))
        sum = w_list[i] + s_list[j]
        if z <= int(100 * e / (e + 100)) and z > c_ans and sum <= f:
            c_ans = z
            w_ans = w_list[i]
            s_ans = s_list[j]

print(str(w_ans + s_ans) + " " + str(s_ans))

Submission status: Wrong Answer

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

w = {0}
s = {0}

for i in range(f+1):
    for j in range(f+1):
        x = 100 * (a * i + b  * j)
        if x <= f:
            w.add(x)

for i in range(f+1):
    for j in range(f+1):
        y = c * i + d  * j
        if y <= f:
            s.add(y)

s_list = list(s)
s_list.sort()
w_list = list(w)
w_list.sort()


c_ans = 0
s_ans = 0
w_ans = 0

for i in range(1, len(w_list)):
    for j in range(1, len(s_list)):
        z = 100 * s_list[j] / (s_list[j] + w_list[i])
        sum = w_list[i] + s_list[j]
        if z <= 100 * e / (e + 100) and z > c_ans and sum <= f:
            c_ans = z
            w_ans = w_list[i]
            s_ans = s_list[j]

print(str(w_ans + s_ans) + " " + str(s_ans))

Submission status: Wrong Answer

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

w = {0}
s = {0}

for i in range(f+1):
    for j in range(f+1):
        x = 100 * (a * i + b  * j)
        if x < f:
            w.add(x)

for i in range(f+1):
    for j in range(f+1):
        y = c * i + d  * j
        if y < f:
            s.add(y)

s_list = list(s)
s_list.sort()
w_list = list(w)
w_list.sort()


c_ans = 0
s_ans = 0
w_ans = 0

for i in range(1, len(w_list)):
    for j in range(1, len(s_list)):
        z = 100 * s_list[j] / (s_list[j] + w_list[i])
        sum = w_list[i] + s_list[j]
        if z <= 100 * e / (e + 100) and z > c_ans and sum <= f:
            c_ans = z
            w_ans = w_list[i]
            s_ans = s_list[j]

print(str(w_ans + s_ans) + " " + str(s_ans))

Submission status: Wrong Answer

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

w = {0}
s = {0}

for i in range(f+1):
    for j in range(f+1):
        x = 100 * (a * i + b  * j)
        if x < f:
            w.add(x)

for i in range(f+1):
    for j in range(f+1):
        y = c * i + d  * j
        if y < f:
            s.add(y)

s_list = list(s)
s_list.sort()
w_list = list(w)
w_list.sort()


c_ans = 0
s_ans = 0
w_ans = 0

for i in range(1, len(w_list)):
    for j in range(1, len(s_list)):
        z = int(100 * s_list[j] / (s_list[j] + w_list[i])) 
        if z <= int(100 * e / (e + 100)) and z > c_ans:
            c_ans = z
            w_ans = w_list[i]
            s_ans = s_list[j]

print(str(w_ans + s_ans) + " " + str(s_ans))

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
s, w = (0, 0)
water_list = [False] * (6000)
sugar_list = [False] * (6000)
water_list[0] = True
sugar_list[0] = True
for i in range(F):
    water_list[i + A * 100] = water_list[i + A * 100] or water_list[i]
    water_list[i + B * 100] = water_list[i + B * 100] or water_list[i]
    sugar_list[i + C] = sugar_list[i + C] or sugar_list[i]
    sugar_list[i + D] = sugar_list[i + D] or sugar_list[i]

for wi in range(0, F + 1, 100):
    for si in range(F + 1):
        if si <= (wi / 100) * E and si + wi <= F and water_list[wi] and sugar_list[si]:
            if (si * (s + w) > s * (si + wi)) or (s == 0 and si > 0):
                s, w = (si, wi)
print('{} {}'.format(s + w, s))

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
s, w = (0, 0)
water_list = [False] * (6000)
sugar_list = [False] * (6000)
water_list[0] = True
sugar_list[0] = True
for i in range(F):
    water_list[i + A * 100] = water_list[i + A * 100] or water_list[i]
    water_list[i + B * 100] = water_list[i + B * 100] or water_list[i]
    sugar_list[i + C] = sugar_list[i + C] or sugar_list[i]
    sugar_list[i + D] = sugar_list[i + D] or sugar_list[i]

for si in range(0, F + 1, 100):
    for wi in range(F + 1):
        if si <= (wi / 100) * E and si + wi <= F and water_list[i] and sugar_list[j]:
            if si * (s + w) > s * (si + wi):
                s, w = (si, wi)
print('{} {}'.format(s + w, s))

Submission status: Wrong Answer

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

A = 100 * A
B = 100 * B

max_suger = F * E / (100 + E)
max_water = F * 100 / (100 + E)

A_max = int(max_water // A)
B_max = int(max_water // B)
water = []
for i in range(A_max + 1):
  for j in range(B_max + 1):
    if not ((i == 0) and (j == 0)):
        water.append(A * i + B * j)
      
suger = []
C_max = int(max_suger // C )
D_max = int(max_suger // D )
for i in range(C_max + 1):
  for j in range(D_max + 1):
    if not ((i == 0) and (j == 0)):
        suger.append(C * i + D * j)  
    
density = 0
mizu = 0
sato = 0
max_den = 100 * E / (100 + E)
for i in range(len(suger)):
  for j in range(len(water)):
    den = 100 * suger[i] / (suger[i] + water[j])
    if (den <= max_den) and ((suger[i] + water[j]) <= F):
      density = max(density, den)
      if density == den:
        mizu = water[j]
        sato = suger[i]

#print(water, suger)        
print(int(mizu + sato), int(sato))

Submission status: Wrong Answer

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

A = 100 * A
B = 100 * B

max_suger = F * E / (100 + E)
max_water = F * 100 / (100 + E)

A_max = int(max_water // A)
B_max = int(max_water // B)
water = []
for i in range(A_max + 1):
  for j in range(B_max + 1):
    if not ((i == 0) and (j == 0)):
      if A * i + B * j <= max_water:
        water.append(A * i + B * j)
      
suger = []
C_max = int(max_suger // C )
D_max = int(max_suger // D )
for i in range(C_max + 1):
  for j in range(D_max + 1):
    if not ((i == 0) and (j == 0)):
      if C * i + D * j <= max_suger:
        suger.append(C * i + D * j)  
    
density = 0
mizu = 0
sato = 0
max_den = 100 * E / (100 + E)
for i in range(len(suger)):
  for j in range(len(water)):
    den = 100 * suger[i] / (suger[i] + water[j])
    if (den <= max_den) and ((suger[i] + water[j]) <= F):
      density = max(density, den)
      if density == den:
        mizu = water[j]
        sato = suger[i]

print(int(mizu + sato), int(sato))

Submission status: Wrong Answer

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

A = 100 * A
B = 100 * B

max_suger = F * E / (100 + E)
max_water = F * 100 / (100 + E)

A_max = int(max_water // A)
B_max = int(max_water // B)
water = []
for i in range(A_max + 1):
  for j in range(B_max + 1):
    if not ((i == 0) and (j == 0)):
      if A * i + B * j <= max_water:
        water.append(A * i + B * j)
      
suger = []
C_max = int(max_suger // C )
D_max = int(max_suger // D )
for i in range(C_max + 1):
  for j in range(D_max + 1):
    if not ((i == 0) and (j == 0)):
      if C * i + D * j <= max_suger:
        suger.append(C * i + D * j)  
    
density = 0
mizu = 0
sato = 0
max_den = 100 * E / (100 + E)
for i in range(len(suger)):
  for j in range(len(water)):
    den = 100 * suger[i] / (suger[i] + water[j])
    if den <= max_den:
      density = max(density, den)
      if density == den:
        mizu = water[j]
        sato = suger[i]

print(int(mizu + sato), int(sato))

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
if a==g:
    print(str(100*a)+" "+"0")
    sys.exit()
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
data.sort()
ans=0
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    if m==0:
        continue
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
    else:
        m=bisect(data,f-k)
        if m==0:
            continue
        o=data[m-1]
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)

Submission status: Wrong Answer

Solution code:
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
data.sort()
ans=0
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    if m==0:
        continue
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
    else:
        m=bisect(data,f-k)
        if m==0:
            continue
        o=data[m-1]
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)

Submission status: Wrong Answer

Solution code:
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
data.sort()
ans=0
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    if m==0:
        continue
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
A, B, C, D, E, F = [int(x) for x in stdin.readline().rstrip().split()]

water = set()
for i in range(0, F//(100*A)+1):
    for j in range(0, F//(100*B)+1):
        water.add(A*i*100+B*j*100)

sugar = set()
capa = math.ceil(F/100)*E
for k in range(0, capa//C+1):
    for l in range(0, capa//D+1):
        sugar.add(C*k+D*l)

W = 0
S = 0
conc = 0
#print(water)
#print(sugar)
for w in water:
    for s in sugar:
        tmp = 0
        if w + s > F:
            continue
        if w+s == 0:
            continue
        if s > (w / 100)*E:
            continue
        tmp = (100*s)/(w+s)
        if tmp > conc:
            conc = tmp
            W = w
            S = s
        #print(conc,w,s)
print(W+S,S)

Submission status: Wrong Answer

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

if F < 100 * A + C:
    print(100*A)
    exit(0)
else:
    if 100 * A + A*E <= F:
        if A*E % C == 0 or A*E % D == 0:
            print(100 * A + A*E, A*E)
            exit(0)
        if 100*B + B * E <= F:
            if B*E % C == 0 or B*E % D == 0:
                print(100 * B + B*E, B*E)
                exit(0)

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

sugar = []
for i in range(F//C + 1):
    for j in range(F // D + 1):
        if C * i + D*j <= F:
            sugar.append(C * i + D*j)
        else:
            break
ans = [100*A, 0]
for x in water:
    if x == 0:
        continue
    for y in sugar:
        if x + y <= F and y <= (x/100)*E:
            if ans[1]/ans[0] < y / (x+y):
                ans = [x+y, y]

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

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [water_1, water_2, suger_1, suger_2, max_percent,
        max_weight] = string_to_int(inputs[0])
    water_1 *= 100
    water_2 *= 100

    water_set = set()
    water_1_weight = 0
    while water_1_weight <= max_weight:
        water_2_weight = 0
        while water_1_weight + water_2_weight <= max_weight:
            water_set.add(water_1_weight + water_2_weight)
            water_2_weight += water_2
        water_1_weight += water_1

    suger_set = set()
    suger_1_weight = 0
    # max_suger = max_weight // 2
    max_suger = max_weight - (max_weight / (1 + (max_percent/100)))
    while suger_1_weight <= max_suger:
        suger_2_weight = 0
        while suger_1_weight + suger_2_weight <= max_suger:
            suger_set.add(suger_1_weight + suger_2_weight)
            suger_2_weight += suger_2
        suger_1_weight += suger_1

    def calc_percent(w, s):
        if w + s == 0:
            return 0
        return (100 * s / w)

    m_percent = 0
    m_total = 0
    m_suger = 0
    for w in water_set:
        for s in suger_set:
            if w + s <= max_weight and w >= s:
                p = calc_percent(w, s)
                if p > m_percent and p <= max_percent:
                    m_percent = p
                    m_total = w + s
                    m_suger = s
    return "{} {}".format(m_total, m_suger)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [water_1, water_2, suger_1, suger_2, max_percent,
        max_weight] = string_to_int(inputs[0])
    water_1 *= 100
    water_2 *= 100

    water_set = set()
    water_1_weight = 0
    while water_1_weight <= max_weight:
        water_2_weight = 0
        while water_1_weight + water_2_weight <= max_weight:
            water_set.add(water_1_weight + water_2_weight)
            water_2_weight += water_2
        water_1_weight += water_1
    water_set.remove(0)

    suger_set = set()
    suger_1_weight = 0
    # max_suger = max_weight // 2
    max_suger = max_weight - (max_weight / (1 + (max_percent/100)))
    while suger_1_weight <= max_suger:
        suger_2_weight = 0
        while suger_1_weight + suger_2_weight <= max_suger:
            suger_set.add(suger_1_weight + suger_2_weight)
            suger_2_weight += suger_2
        suger_1_weight += suger_1

    def calc_percent(w, s):
        if w + s == 0:
            return 0
        return (100 * s / w)

    m_percent = 0
    m_total = 0
    m_suger = 0
    for w in water_set:
        for s in suger_set:
            if w + s <= max_weight and w >= s:
                p = calc_percent(w, s)
                if p > m_percent and p <= max_percent:
                    m_percent = p
                    m_total = w + s
                    m_suger = s
    return "{} {}".format(m_total, m_suger)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [water_1, water_2, suger_1, suger_2, max_percent,
        max_weight] = string_to_int(inputs[0])
    water_1 *= 100
    water_2 *= 100

    water_set = set()
    water_1_weight = 0
    while water_1_weight <= max_weight:
        water_2_weight = 0
        while water_1_weight + water_2_weight <= max_weight:
            water_set.add(water_1_weight + water_2_weight)
            water_2_weight += water_2
        water_1_weight += water_1
    water_set.remove(0)

    suger_set = set()
    suger_1_weight = 0
    max_suger = max_weight // 2
    while suger_1_weight <= max_suger:
        suger_2_weight = 0
        while suger_1_weight + suger_2_weight <= max_suger:
            suger_set.add(suger_1_weight + suger_2_weight)
            suger_2_weight += suger_2
        suger_1_weight += suger_1

    def calc_percent(w, s):
        if w + s == 0:
            return 0
        return (100 * s / w)

    m_percent = 0
    m_total = 0
    m_suger = 0
    for w in water_set:
        for s in suger_set:
            if w + s <= max_weight and w >= s:
                p = calc_percent(w, s)
                if p > m_percent and p <= max_percent:
                    m_percent = p
                    m_total = w + s
                    m_suger = s
    return "{} {}".format(m_total, m_suger)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [water_1, water_2, suger_1, suger_2, max_percent,
        max_weight] = string_to_int(inputs[0])
    water_1 *= 100
    water_2 *= 100

    def calc_per(w, s): return (s / (w + s)) * 100

    water_set = set()
    water_1_weight = 0
    while water_1_weight <= max_weight:
        water_2_weight = 0
        while water_1_weight + water_2_weight <= max_weight:
            water_set.add(water_1_weight + water_2_weight)
            water_2_weight += water_2
        water_1_weight += water_1
    water_set.remove(0)

    suger_set = set()
    suger_1_weight = 0
    while suger_1_weight <= max_weight // 2:
        suger_2_weight = 0
        while suger_1_weight + suger_2_weight <= max_weight // 2:
            suger_set.add(suger_1_weight + suger_2_weight)
            suger_2_weight += suger_2
        suger_1_weight += suger_1

    def calc_percent(w, s):
        if w + s == 0:
            return 0
        return (100 * s // (w+s))

    m_percent = 0
    m_total = 0
    m_suger = 0
    for w in water_set:
        for s in suger_set:
            if w + s <= max_weight and w >= s:
                p = calc_percent(w, s)
                if p > m_percent and p <= max_percent:
                    m_percent = p
                    m_total = w + s
                    m_suger = s
    return "{} {}".format(m_total, m_suger)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
sato = 0
w = 0
    
while f > 0:
    try:
        if sato/(sato+w) == e/(e+100):
            break
    except ZeroDivisionError:
        pass
      
    if w == 0 or sato/(sato+w) > e/(e+100):
        if f > 100*a:
            f -= 100*a
            w += 100*a
        elif f > 100*b:
            f -= 100*b
            w += 100*b
    else:
        if sato + d <= e*w//100:
            f -= d
            sato += d
        elif sato + c <= e*w//100:
            f -= c
            sato += c
        else:
            break

print(w+sato, sato)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
sato = 0
w = 0
    
while f > 0:
    print(w+sato, sato)
    try:
        if sato/(sato+w) == e/(e+100):
            break
    except ZeroDivisionError:
        pass
      
    if w == 0 or sato/(sato+w) > e/(e+100):
        if f > 100*a:
            f -= 100*a
            w += 100*a
        elif f > 100*b:
            f -= 100*b
            w += 100*b
    else:
        if sato + d <= e*w//100:
            f -= d
            sato += d
        elif sato + c <= e*w//100:
            f -= c
            sato += c
        else:
            break

print(w+sato, sato)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
sato = 0
w = 0
if f > 100*b:
    f -= 100*b
    w += 100*b
elif f > 100*a:
    f -= 100*a
    w += 100*a

while sato < e*w//100 and f > 0:
    if sato + d <= e*w//100:
        f -= d
        sato += d
    elif sato + c <= e*w//100:
        f -= c
        sato += c
    else:
        break

print(w+sato, sato)

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    A_enable = []
    B_enable = []
    AB_enable = []
    a = 0
    while a <= F:
        A_enable.append(a)
        a += A*100
    
    b = 0
    while b <= F:
        B_enable.append(b)
        b += B*100

    for aa in A_enable:
        for bb in B_enable:
            if aa+bb<=F:
                AB_enable.append(aa+bb)
    AB_enable = sorted(list(set(AB_enable)))
    AB_enable.pop(0)

    C_enable = []
    D_enable = []
    CD_enable = []
    c = 0
    while c <= F:
        C_enable.append(c)
        c += C
    d = 0
    while d <= F:
        D_enable.append(d)
        d += D

    for cc in C_enable:
        for dd in D_enable:
            if cc+dd <= F:
                CD_enable.append(cc+dd)
    CD_enable = sorted(list(set(CD_enable)))
    CD_enable.pop(0)

    answer = [0,0,0] 
    for aabb in AB_enable:
        for ccdd in CD_enable:
            if (aabb/100)*E >= ccdd and aabb+ccdd<=F and answer[2] < ccdd/(aabb+ccdd): 
                
                answer[0] = aabb
                answer[1] = ccdd
                answer[2] = ccdd/(aabb+ccdd)
    
    print(answer[0]+answer[1], answer[1])
            
    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


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    A_enable = []
    B_enable = []
    AB_enable = []
    a = 0
    while a <= F:
        A_enable.append(a)
        a += A*100
    
    b = 0
    while b <= F:
        B_enable.append(b)
        b += B*100

    for aa in A_enable:
        for bb in B_enable:
            if aa+bb<=F:
                AB_enable.append(aa+bb)
    AB_enable = sorted(list(set(AB_enable)))
    AB_enable.pop(0)

    C_enable = []
    D_enable = []
    CD_enable = []
    c = 0
    while c <= F:
        C_enable.append(c)
        c += C
    d = 0
    while d <= F:
        D_enable.append(d)
        d += D

    for cc in C_enable:
        for dd in D_enable:
            if cc+dd <= F:
                CD_enable.append(cc+dd)
    CD_enable = sorted(list(set(CD_enable)))
    CD_enable.pop(0)

    answer = [0,0,10**-9] 
    for aabb in AB_enable:
        for ccdd in CD_enable:
            if (aabb/100)*E >= ccdd and aabb+ccdd<=F and answer[2] < ccdd/(aabb+ccdd): 
                
                answer[0] = aabb
                answer[1] = ccdd
                answer[2] = ccdd/(aabb+ccdd)
    
    print(answer[0]+answer[1], answer[1])
            
    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())
dp = [[0 for j in range(f + 1)] for i in range(f // 2 + 1)]
opt = 0
opt_sugar = -1
opt_water = -1
dp[0][0] = 0.5
bound = e / (e + 100)
for i in range(c, f // 2 + 1):
    for j in range(i, f + 1):
        if j >= 100 * b:
            if dp[i][j - 100 * b] > 0 or dp[i][j - 100 * a]:
                dp[i][j] = i / j
            elif i >= d and (dp[i - d][j - d] > 0 or dp[i - c][j - c] > 0):
                dp[i][j] = i / j
            elif i >= c and dp[i - c][j - c] > 0:
                dp[i][j] = i / j
            if bound >= dp[i][j] > opt:
                opt = dp[i][j]
                opt_sugar = i
                opt_water = j - i
        elif j >= 100 * a:
            if dp[i][j - 100 * a] > 0:
                dp[i][j] = i / j
            elif i >= d and (dp[i - d][j - d] > 0 or dp[i - c][j - c] > 0):
                dp[i][j] = i / j
            elif i >= c and dp[i - c][j - c] > 0:
                dp[i][j] = i / j
            if bound >= dp[i][j] > opt:
                opt = dp[i][j]
                opt_sugar = i
                opt_water = j - i
        elif j >= d:
            if i >= d and (dp[i - d][j - d] > 0 or dp[i - c][j - c] > 0):
                dp[i][j] = i / j
            elif i >= c and dp[i - c][j - c] > 0:
                dp[i][j] = i / j
            if bound >= dp[i][j] > opt:
                opt = dp[i][j]
                opt_sugar = i
                opt_water = j - i
        elif  j >= c:
            if i >= c and dp[i - c][j - c] > 0:
                dp[i][j] = i / j
            if bound >= dp[i][j] > opt:
                opt = dp[i][j]
                opt_sugar = i
                opt_water = j - i

print(opt_sugar + opt_water, opt_sugar)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w_m=int((f*100/(100+e)))//100*100
s_m=f*e//(100+e)
answ=100*a
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if w!=0:
            for k in range(s_m//c+1):
                for l in range((s_m-k*c)//d+1):
                    s=k*c+l*d
                    if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                        answ=w
                        anss=s
print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w_m=int((f*100/(100+e)))//100*100
s_m=f*e//(100+e)
answ=float('inf')
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if w!=0:
            for k in range(s_m//c+1):
                for l in range((s_m-k*c)//d+1):
                    s=k*c+l*d
                    if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                        answ=w
                        anss=s
print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w_m=-(-f//(100+e))*100
s_m=f//(100+e)*e
answ=float('inf')
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if w!=0:
            for k in range(s_m//c+1):
                for l in range((s_m-k*c)//d+1):
                    s=k*c+l*d
                    if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                        answ=w
                        anss=s
print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w_m=-(-f//(100+e))*100
s_m=f//(100+e)*e
noudo=0
answ=0
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if w==0:
            pass
        else:
            for k in range(s_m//c+1):
                for l in range((s_m-k*c)//d+1):
                    s=k*c+l*d
                    if (noudo<s/(s+w)) and (s/(s+w)<=e/(100+e)):
                        noudo=s/(s+w)
                        answ=w
                        anss=s
print(answ+anss,anss)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
w_m=-(-f//(100+e))*100
s_m=f//(100+e)*e
w=w_m//(100*a)*(100*a)
s=s_m//c*c
wn=w_m//(100*b)
noudo=0
answ=0
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//b+1):
        w=(i*a+j*b)*100
        if w==0:
            pass
        else:
            for k in range(s_m//c+1):
                for l in range((s_m-k*c)//d+1):
                    s=k*c+l*d
                    if (noudo<s/(s+w)) and (s/(s+w)<=e/(100+e)):
                        noudo=s/(s+w)
                        answ=w
                        anss=s
print(answ+anss,anss)