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:
__DEUBG__ = 0

import math
import sys

def pat_water(a, b, limit):
    for i in range(int(limit/a) + 1):
        if a * i > limit:
            continue
        for j in range(int(limit/b) + 1):
            if b * j > limit:
                continue
            if i ==  j == 0:
                continue
            if a*i + b*j <= limit:
                yield a*i + b*j

def pat_sugar(c, d, limit):
    for i in range(int(limit/c) + 1):
        if c * i > limit:
            continue
        for j in range(int(limit/d) + 1):
            if c*i + d*j <= limit:
                yield c*i + d*j

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

if e == 0:
    print(a * 100, 0)
    sys.exit(0)

if __DEUBG__:
    print(tuple(pat_water(a * 100, b * 100, f)))
    print(tuple(pat_sugar(c, d, f)))

density = 0, 0, 0
for water in pat_water(a * 100, b * 100, f):
    water_limit = min(water * e / 100 , f - water)
    for sugar in pat_sugar(c, d, water_limit):
        if water + sugar > f:
            continue

        tmp_density = (sugar / (water + sugar))
        if tmp_density == (e/100):
            print('%d %d'%(sugar + water, sugar))
            sys.exit(0)
        if tmp_density < (e/100):
            if tmp_density > density[0]:
                density = tmp_density, sugar + water, sugar

print('%d %d'%(density[1], density[2]))

Submission status: Wrong Answer

Solution code:
import math
import sys

__DEUBG__ = 0
def pat_water(a, b, limit):
    for i in range(int(limit/a) + 1):
        if a * i > limit:
            continue
        for j in range(int(limit/b) + 1):
            if b * j > limit:
                continue
            if i ==  j == 0:
                continue
            if a*i + b*j <= limit:
                yield a*i + b*j

def pat_sugar(c, d, limit):
    for i in range(int(limit/c) + 1):
        if c * i > limit:
            continue
        for j in range(int(limit/d) + 1):
            if c*i + d*j <= limit:
                yield c*i + d*j

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

if e == 0:
    print(0, 0)
    sys.exit(0)

if __DEUBG__:
    print(tuple(pat_water(a * 100, b * 100, f)))
    print(tuple(pat_sugar(c, d, f)))

density = 0, 0, 0
for water in pat_water(a * 100, b * 100, f):
    water_limit = min(water * e / 100 , f - water)
    for sugar in pat_sugar(c, d, water_limit):
        if water + sugar > f:
            continue

        tmp_density = (sugar / (water + sugar))
        if tmp_density == (e/100):
            print('%d %d'%(sugar + water, sugar))
            sys.exit(0)
        if tmp_density < (e/100):
            if tmp_density > density[0]:
                density = tmp_density, sugar + water, sugar

print('%d %d'%(density[1], density[2]))

Submission status: Wrong Answer

Solution code:
import math

__DEUBG__ = 0
def pat_water(a, b, limit):
    for i in range(int(limit/a) + 1):
        if a * i > limit:
            continue
        for j in range(int(limit/b) + 1):
            if b * j > limit:
                continue
            if i ==  j == 0:
                continue
            if a*i + b*j <= limit:
                yield a*i + b*j

def pat_sugar(c, d, limit):
    for i in range(int(limit/c) + 1):
        if c * i > limit:
            continue
        for j in range(int(limit/d) + 1):
            if c*i + d*j <= limit:
                yield c*i + d*j

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

if __DEUBG__:
    print(tuple(pat_water(a * 100, b * 100, f)))
    print(tuple(pat_sugar(c, d, f)))

density = 0, 0, 0
for water in pat_water(a * 100, b * 100, f):
    water_limit = min(water * e / 100 , f - water)
    for sugar in pat_sugar(c, d, water_limit):
        if water + sugar > f:
            continue

        tmp_density = (sugar / (water + sugar))
        if tmp_density == (e/100):
            print('%d %d'%(sugar + water, sugar))
            sys.exit(0)
        if tmp_density < (e/100):
            if tmp_density > density[0]:
                density = tmp_density, sugar + water, sugar

print('%d %d'%(density[1], density[2]))

Submission status: Wrong Answer

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

s1 = set()
for i in range(0, 31, A):
    for j in range(0, 31, B):
        if 0 < i + j and i * 100 + j * 100 <= F:
            s1.add(i + j)

s2 = set()
for i in range(0, F, C):
    for j in range(0, F, D):
        if i + j <= F:
            s2.add(i + j)

conc = 0
max_conc = E / (100 + E)
total = 0
sugar = 0
for ab in s1:
    for cd in s2:
        if ab * 100 + cd <= F:
            tmp_conc = cd / (ab * 100 + cd)
            if max_conc >= tmp_conc and conc < tmp_conc:
                conc = tmp_conc
                total = ab * 100 + cd
                sugar = cd

print(total, sugar)

Submission status: Wrong Answer

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

lst1 = []
for i in range(0, F // 100):
    for j in range(0, F // 100):
        ret = A * i * 100 + B * j * 100
        if ret > 0 and ret < F:
            lst1.append(ret)
        if ret < F:
            break

lst2 = []
for i in range(0, F):
    for j in range(0, F):
        ret = C * i + D * j
        if ret > 0 and ret < F:
            lst2.append(ret)
        if ret < F:
            break


conc = 0
max_conc = E / (100 + E)
total = 0
sugar = 0
for a in set(lst1):
    for b in set(lst2):
        if a + b <= F:
            t = b / (a + b)
            if max_conc >= t and conc < t:
                conc = t
                total = a + b
                sugar = b

print(total, sugar)

Submission status: Wrong Answer

Solution code:
def concentration(water, suger):
  return 100 * suger / (water + suger)

WATER_A, WATER_B, SUGER_C, SUGER_D, MELT_PER_100, LIMIT = map(int, input().split())

WATER_A *= 100
WATER_B *= 100
# 砂糖の溶解率の上限
MELT_PERCENT_LIMIT = concentration(100, MELT_PER_100)

wa = wb = sc = sd = 0

water_set = set()
while wa * WATER_A <= LIMIT:
  while wb * WATER_B <= LIMIT:
    water = wa * WATER_A + wb * WATER_B
    if water <= LIMIT:
      water_set.add(water)
    wb += 1
  wb = 0
  wa += 1

suger_set = set()
while sc * SUGER_C <= LIMIT:
  while sd * SUGER_D <= LIMIT:
    suger = sc * SUGER_C + sd * SUGER_D
    if suger <= LIMIT:
      suger_set.add(suger)
    sd += 1
  sd = 0
  sc += 1

ans_suger_water = 0
ans_suger = 0
# 最大溶解率を保持するための変数
max_concentration = 0

for water in water_set:
  for suger in suger_set:
    # 砂糖水の量が0より大きく制限量以下以外の場合は次のループへ
    if not (0 < water + suger <= LIMIT):
      continue
    # 砂糖濃度計算
    suger_precent = concentration(water, suger)
    # 砂糖濃度が最高を更新かつ限界濃度を超えていなければ答えを更新
    if max_concentration < suger_precent <= MELT_PERCENT_LIMIT:
      max_concentration = suger_precent
      ans_suger_water = water + suger
      ans_suger = suger

print(ans_suger_water, ans_suger)

Submission status: Wrong Answer

Solution code:
def concentration(water, suger):
  return 100 * suger / (water + suger)

WATER_A, WATER_B, SUGER_C, SUGER_D, MELT_PER_100, LIMIT = map(int, input().split())

WATER_A *= 100
WATER_B *= 100
MELT_PERCENT = concentration(100, MELT_PER_100)

max_concentration = 0
ans_suger_water = 0
ans_suger = 0

wa = wb = sc = sd = 0

water_set = set()
while wa * WATER_A <= LIMIT:
  while wb * WATER_B <= LIMIT:
    water = wa * WATER_A + wb * WATER_B
    if water <= LIMIT:
      water_set.add(water)
    wb += 1
  wb = 0
  wa += 1

suger_set = set()
while sc * SUGER_C <= LIMIT:
  while sd * SUGER_D <= LIMIT:
    suger = sc * SUGER_C + sd * SUGER_D
    if suger <= LIMIT:
      suger_set.add(suger)
    sd += 1
  sd = 0
  sc += 1

ans_suger_water = 0
ans_suger = 0

max_concentration = 0
for water in water_set:
  for suger in suger_set:
    # 砂糖水の量が0より大きく制限量以下以外の場合は次のループへ
    if not (0 < water + suger <= LIMIT):
      continue
    # 砂糖濃度計算
    suger_precent = concentration(water, suger)
    # 砂糖濃度が最高を更新かつ限界濃度を超えていなければ答えを更新
    if max_concentration < suger_precent <= MELT_PERCENT:
      max_concentration = suger_precent
      ans_suger_water = water + suger
      ans_suger = suger

print(ans_suger_water, ans_suger)

Submission status: Wrong Answer

Solution code:
import sys

A, B, C, D, E, F = map(int, sys.stdin.readline().rstrip().split())

q = [A, B]
water = []
while q:
    num = q.pop()
    if 100 * num <= F:
        water.append(num)
    else:
        continue
    q.append(num + A)
    q.append(num + B)

water = set(water)
w_ans = 0
s_ans = 0
nodo_ans = 0
V = [C, D]

for w in water:
    max_s = min(E * w, F - w * 100) # 溶かせる砂糖の量の最大値
    dp = [[0] * (max_s + 1) for _ in range(3)]
    dp[0][0] = 1
    for i in range(2):
        v = V[i]
        for j in range(max_s + 1):
            if j - v >= 0:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - v], dp[i + 1][j - v])
            else:
                dp[i + 1][j] = dp[i][j]

    for i, d in enumerate(dp[2][1:], 1):
        if d > 0:
            nodo = i * 100 / (100 * w + i)
            if nodo_ans < nodo:
                s_ans = i
                w_ans = w * 100
                nodo_ans = nodo

print(w_ans + s_ans, s_ans)

Submission status: Wrong Answer

Solution code:
import itertools
def main():
  A, B, C, D, E, F = map(int, input().split())
  water = [100*A*(i)+100*B*(j) for i in range(31) for j in range(31-i)]
  water = set(water)
  sugar_max = int(F*(E/(100+E)))
  sugar = [C*i + D*j for i in range(sugar_max//C+10) for j in range((sugar_max-C*i)//D+10)]
  sugar = set(sugar)
  ans = [0, 0]
  max_den = 0
  for p in itertools.product(water, sugar):
    if p[0] == 0 and p[1] == 0:continue
    if max_den < p[1]/(p[0]+p[1]) <= E/(100+E) and p[0] + p[1] <= F:
      max_den = p[1]/(p[0]+p[1])
      ans[0] = p[0] + p[1]
      ans[1] = p[1]
  print(*ans)
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
import itertools
def main():
  A, B, C, D, E, F = map(int, input().split())
  water = [100*A*(i)+100*B*(j) for i in range(31) for j in range(31-i)]
  water = set(water)
  sugar_max = int(F*(E/(100+E)))
  sugar = [C*i + D*j for i in range(sugar_max//C+10) for j in range((sugar_max-C*i + 10)//D+1)]
  sugar = set(sugar)
  ans = [0, 0]
  max_den = 0
  for p in itertools.product(water, sugar):
    if p[0] == 0 and p[1] == 0:continue
    if max_den < p[1]/(p[0]+p[1]) <= E/(100+E) and p[0] + p[1] <= F:
      max_den = p[1]/(p[0]+p[1])
      ans[0] = p[0] + p[1]
      ans[1] = p[1]
  print(*ans)
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
import itertools
def main():
  A, B, C, D, E, F = map(int, input().split())
  water = [100*A*(i)+100*B*(j) for i in range(F//(100*A)+ 1) for j in range((F-(100*A*i))//(100*B) + 1)]
  water = set(water)
  sugar_max = int(F*(E/(100+E)))
  sugar = [C*i + D*j for i in range(sugar_max//C+1) for j in range((sugar_max-C*i)//D+1)]
  sugar = set(sugar)
  ans = [0, 0]
  max_den = 0
  for p in itertools.product(water, sugar):
    if p[0] == 0 and p[1] == 0:continue
    if max_den < p[1]/(p[0]+p[1]) <= E/(100+E) and p[0] + p[1] <= F:
      max_den = p[1]/(p[0]+p[1])
      ans[0] = p[0] + p[1]
      ans[1] = p[1]
  print(*ans)
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    water = [0]*F**2
    sugar = [0]*F**2

    sugar_idx = 0
    for i in range(F+1):
        for j in range(F+1):
            y = i*C+j*D
            if y <= F:
                sugar[sugar_idx] = y
                sugar_idx += 1

    water_idx = 0
    for i in range(F+1):
        for j in range(F+1):
            x = i*100*A+j*200*D
            if x <= F:
                water[water_idx] = x
                water_idx += 1

    dens = 0
    ans = (0, 0)

    for i in range(water_idx):
        for j in range(sugar_idx):
            w=water[i]
            s=sugar[j]
            if 0 < w+s <= F:
                if s/(w+s) > dens and s/(w+s) <= E/(100+E):
                    dens = s/(w+s)
                    ans = (w+s, s)
    print(*ans)


resolve()

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D, E, F = list(map(int, input().split(' ')))
    max_p = 0
    ans_total, ans_sugar = 0, 0
    a = 0
    while 100 * A * a <= F:
        b = 0
        while 100 * (A * a + B * b) <= F:
            if a == b == 0:
                b += 1
                continue
            c = 0
            while 100 * (A * a + B * b) + C * c <= F:
                if E * (A * a + B * b) < C * c:
                    break
                d = 0
                while 100 * (A * a + B * b) + C * c + D * d <= F:
                    if E * (A * a + B * b) < C * c + D * d:
                        break
                    p = 100 * (C * c + D * d) / (100 * (A * a + B * b) + C * c + D * d)
                    if p > max_p:
                        max_p = p
                        ans_sugar = C * c + D * d
                        ans_total = 100 * (A * a + B * b) + ans_sugar
                    d += 1
                c += 1
            b += 1
        a += 1
    print('{} {}'.format(ans_total, ans_sugar))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D, E, F = list(map(int, input().split(' ')))
    max_p = 0
    ans_total, ans_sugar = 0, 0
    a = 0
    while 100 * A * a < F:
        b = 0
        while 100 * (A * a + B * b) < F:
            if a == b == 0:
                b += 1
                continue
            c = 0
            while 100 * (A * a + B * b) + C * c < F:
                if E * (A * a + B * b) < C * c:
                    break
                d = 0
                while 100 * (A * a + B * b) + C * c + D * d < F:
                    if E * (A * a + B * b) < C * c + D * d:
                        break
                    p = 100 * (C * c + D * d) / (100 * (A * a + B * b) + C * c + D * d)
                    if p > max_p:
                        max_p = p
                        ans_sugar = C * c + D * d
                        ans_total = 100 * (A * a + B * b) + ans_sugar
                    d += 1
                c += 1
            b += 1
        a += 1
    print('{} {}'.format(ans_total, ans_sugar))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def judgement(x,y):
    flag = True
    if 100*y > e*x:
        flag = False
    if x+y > f:
        flag = False
    return flag


q = deque([(100*a, 0)])
used = set()
used.add((100*a, 0))
if 100*b <= f:
    q.append((100*b, 0))
    used.add((100*b, 0))
ans = (0,0)
per = 0
while q:
    tar = q.popleft()
    step = [(tar[0]+100*a, tar[1]), (tar[0]+100*b, tar[1]),
            (tar[0], tar[1]+c), (tar[0], tar[1]+d)]
    for i in step:
        if i not in used:
            used.add(i)
            if judgement(i[0], i[1]):
                q.append(i)
                if per*i[0] < i[1]:
                    per = i[1]/i[0]
                    ans = i
print(ans[0]+ans[1], ans[1])

Submission status: Wrong Answer

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

def judgement(x,y):
    flag = True
    if 100*y > e*x:
        flag = False
    if x+y > f:
        flag = False
    return flag


q = deque([(100*a, 0)])
used = set()
used.add((100*a, 0))
if 100*b <= f:
    q.append((100*b, 0))
    used.add((100*b, 0))
ans = (-1,-1)
per = -1
while q:
    tar = q.popleft()
    step = [(tar[0]+100*a, tar[1]), (tar[0]+100*b, tar[1]),
            (tar[0], tar[1]+c), (tar[0], tar[1]+d)]
    for i in step:
        if i not in used:
            used.add(i)
            if judgement(i[0], i[1]):
                q.append(i)
                if per*i[0] < i[1]:
                    per = i[1]/i[0]
                    ans = i
print(ans[0]+ans[1], ans[1])

Submission status: Wrong Answer

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

def judgement(x,y):
    flag = True
    if y/x > e/100:
        flag = False
    if x+y > f:
        flag = False
    return flag


q = deque([(100*a, 0), (100*b, 0)])
used = set()
used.add((100*a, 0))
used.add((100*b, 0))
ans = (-1,-1)
per = -1
while q:
    tar = q.popleft()
    step = [(tar[0]+100*a, tar[1]), (tar[0]+100*b, tar[1]),
            (tar[0], tar[1]+c), (tar[0], tar[1]+d)]
    for i in step:
        if i not in used:
            used.add(i)
            if judgement(i[0], i[1]):
                q.append(i)
                if per < i[1]/i[0]:
                    per = i[1]/i[0]
                    ans = i
print(ans[0]+ans[1], ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
"""
整数を空白区切りで2つ出力せよ。 
1つ目は求める砂糖水の質量、
2つ目はそれに溶けている砂糖の質量
"""
ans1 = 100
ans2 = 0

if a>b:
    a, b = b, a
    
flag = True

for _a in range(f//(a*100) + 1):
    for _b in range((f - _a*100)//(b*100) + 1):
        for _c in range((f - _a*100 - _b*100)//c + 1):
            for _d in range((f - _a*100 - _b*100 - _c * c)//d + 1):
                if a*100*_a+b*100*_b+c*_c+d*_d == 0:
                    continue                
                if a*100*_a+b*100*_b+c*_c+d*_d > f:
                    continue  
                    
                if (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) == e/(100+e):
                    print(a*100*_a+b*100*_b+c*_c+d*_d, c*_c+d*_d)
                    flag = False
                    break
                elif (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) > e/(100+e):
                    continue
                else:
                    if ans2/ans1 < (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d):
                        ans1 = a*100*_a+b*100*_b+c*_c+d*_d
                        ans2 = c*_c+d*_d
            if flag:
                continue
            else:
                break
        if flag:
            continue
        else:
            break
    if flag:
        continue
    else:
        break

else:
    print(ans1, ans2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
"""
整数を空白区切りで2つ出力せよ。 
1つ目は求める砂糖水の質量、
2つ目はそれに溶けている砂糖の質量
"""
ans1 = 100
ans2 = 0

if a>b:
    a, b = b, a

for _a in range(f//(a*100) + 1):
    for _b in range((f - _a*100)//(b*100) + 1):
        for _c in range((f - _a*100 - _b*100)//c + 1):
            for _d in range((f - _a*100 - _b*100 - _c * c)//d + 1):
                if a*100*_a+b*100*_b+c*_c+d*_d == 0:
                    continue                
                if a*100*_a+b*100*_b+c*_c+d*_d > f:
                    continue                
                if (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) == e/(100+e):
                    print(a*100*_a+b*100*_b+c*_c+d*_d, c*_c+d*_d)
                    break
                elif (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) > e/(100+e):
                    continue
                else:
                    if ans2/ans1 < (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d):
                        ans1 = a*100*_a+b*100*_b+c*_c+d*_d
                        ans2 = c*_c+d*_d
    print(_a)

else:
    print(ans1, ans2)

Submission status: Wrong Answer

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

    maxConcentration = 0
    resSugarWater = 0
    resSugar = 0

    for i in range(31):
        for j in range((29 * a * i // b) + 1):
            water = (i * a + j * b) * 100
            possibleSugar = int(min(f - water, water * e / 100))
            for k in range((possibleSugar // c) + 1):
                for l in range(((possibleSugar - k * c) // d) + 1):
                    sugar = k * c + l * d

                    if water + sugar > f:
                        break

                    if water + sugar == 0:
                        continue

                    concentration = 100 * sugar / (water + sugar)

                    if concentration > maxConcentration:
                        maxConcentration = concentration
                        resSugarWater = water + sugar
                        resSugar = sugar
    
    print(resSugarWater, resSugar)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    maxConcentration = 0

    for i in range(31):
        for j in range(31 - i * a):
            water = (i * a + j * b) * 100
            possibleSugar = int(min(f - water, water * e / 100))
            for k in range((possibleSugar // c) + 1):
                for l in range(((possibleSugar - k) // d) + 1):
                    sugar = k * c + l * d

                    if water + sugar > f:
                        break

                    if water + sugar == 0:
                        continue

                    concentration = 100 * sugar / (water + sugar)

                    if concentration >= maxConcentration:
                        maxConcentration = concentration
                        resSugarWater = water + sugar
                        resSugar = sugar
    
    print(resSugarWater, resSugar)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

# ABが水、CDが砂糖、Eがとけられる量、Fが上限
A, B, C, D, E, F = getNM()

dp1 = [0] * 31
dp1[0] = 1
for i in range(1, 31):
    if i >= A:
        dp1[i] = max(dp1[i], dp1[i - A])
    if i >= B:
        dp1[i] = max(dp1[i], dp1[i - B])
waterlist = []
for i in range(31):
    if dp1[i] > 0:
        waterlist.append(i)

dp2 = [0] * 3001
dp2[0] = 1
for i in range(1, 3001):
    if i >= C:
        dp2[i] = max(dp2[i], dp2[i - C])
    if i >= D:
        dp2[i] = max(dp2[i], dp2[i - D])
sugerlist = []
for i in range(3001):
    if dp2[i] > 0:
        sugerlist.append(i)

ans = [0, 0]
concent = 0

for water in waterlist[1:]:
    if 100 * water <= F:
        left = F - (water * 100)
        index = bisect_right(sugerlist, min(left, E * water))
        suger = sugerlist[index - 1]
        if suger > 0:
            optconc = (100 * suger) / (100 * water + suger)
            if optconc > concent:
                concent = optconc
                ans = [100 * water + suger, suger]
print(*ans)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

# ABが水、CDが砂糖、Eがとけられる量、Fが上限
A, B, C, D, E, F = getNM()
if E == 0:
    print(0, end = " ")
    print(0)
    exit()

dp1 = [0] * 31
dp1[0] = 1
for i in range(1, 31):
    if i >= A:
        dp1[i] = max(dp1[i], dp1[i - A])
    if i >= B:
        dp1[i] = max(dp1[i], dp1[i - B])
waterlist = []
for i in range(31):
    if dp1[i] > 0:
        waterlist.append(i)

dp2 = [0] * 3001
dp2[0] = 1
for i in range(1, 3001):
    if i >= C:
        dp2[i] = max(dp2[i], dp2[i - C])
    if i >= D:
        dp2[i] = max(dp2[i], dp2[i - D])
sugerlist = []
for i in range(3001):
    if dp2[i] > 0:
        sugerlist.append(i)

ans = [0, 0]
concent = 0

for water in waterlist[1:]:
    if 100 * water <= F:
        left = F - (water * 100)
        index = bisect_right(sugerlist, min(left, E * water))
        suger = sugerlist[index - 1]
        optconc = 100 * suger / (100 * water + suger)
        if optconc > concent:
            concent = optconc
            ans = [100 * water + suger, suger]
print(*ans)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

# ABが水、CDが砂糖、Eがとけられる量、Fが上限
A, B, C, D, E, F = getNM()

dp1 = [0] * 31
dp1[0] = 1
for i in range(1, 31):
    if i >= A:
        dp1[i] = max(dp1[i], dp1[i - A])
    if i >= B:
        dp1[i] = max(dp1[i], dp1[i - B])
waterlist = []
for i in range(31):
    if dp1[i] > 0:
        waterlist.append(i)

dp2 = [0] * 3001
dp2[0] = 1
for i in range(1, 3001):
    if i >= C:
        dp2[i] = max(dp2[i], dp2[i - C])
    if i >= D:
        dp2[i] = max(dp2[i], dp2[i - D])
sugerlist = []
for i in range(3001):
    if dp2[i] > 0:
        sugerlist.append(i)

ans = [0, 0]
concent = 0

for water in waterlist[1:]:
    if 100 * water <= F:
        left = F - (water * 100)
        index = bisect_right(sugerlist, min(left, E * water))
        suger = sugerlist[index - 1]
        optconc = 100 * suger / (100 * water + suger)
        if optconc > concent:
            concent = optconc
            ans = [100 * water + suger, suger]
print(*ans)

Submission status: Wrong Answer

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

water = set()
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        g = 100*a*i+100*b*j
        if g <= f and g != 0:
            water.add(g)

max_con = 0
max_water = 100
max_suger = 0

for w in water:
    suger = set()
    for i in range((f-w)//c+1):
        for j in range((f-w)//d+1):
            if i*c+j*d <= f-w:
                suger.add(i*c+j*d)
    for s in suger:
        if w//100*e >= s:
            con = 100*s/(w+s)
            if con > max_con:
                max_con = con
                max_water = w
                max_suger = s

print(max_water+max_suger,max_suger)

Submission status: Wrong Answer

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

water = set()
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        g = 100*a*i+100*b*j
        if g <= f and g != 0:
            water.add(g)

max_con = 0
max_water = 0
max_suger = 0

for w in water:
    suger = set()
    for i in range((f-w)//c+1):
        for j in range((f-w)//d+1):
            if i*c+j*d <= f-w:
                suger.add(i*c+j*d)
    for s in suger:
        if s+w > f:
            continue
        if w//100*e >= s:
            con = 100*s/(w+s)
            if con > max_con:
                max_con = con
                max_water = w
                max_suger = s

print(max_water+max_suger,max_suger)

Submission status: Wrong Answer

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

water = set()
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        g = 100*a*i+100*b*j
        if g <= f and g != 0:
            water.add(g)

max_con = 0
max_water = 0
max_suger = 0

for w in water:
    suger = set()
    for i in range((f-w)//c+1):
        for j in range((f-w)//d+1):
            if i*c+j*d <= f-w:
                suger.add(i*c+j*d)
    for s in suger:
        if w/100*e >= s:
            con = 100*s/(w+s)
            if con > max_con:
                max_con = con
                max_water = w
                max_suger = s

print(max_water+max_suger,max_suger)

Submission status: Wrong Answer

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

water = set()
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        g = 100*a*i+100*b*j
        if g <= f and g != 0:
            water.add(g)

max_con = 0
max_water = 0
max_suger = 0

for w in water:
    suger = set()
    for i in range((f-w)//c+1):
        for j in range((f-w)//d+1):
            if i*c+j*d <= f-w:
                suger.add(i*c+j*d)
    for s in suger:
        if w//100*e >= s:
            con = 100*s/(w+s)
            if con > max_con:
                max_con = con
                max_water = w
                max_suger = s

print(max_water+max_suger,max_suger)