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

# 作りうる水の量を洗い出す
waters = set()

for i in range(F//(100*A) + 1):
    for j in range((F-100*A*i)//(100*B) + 1):
        w = 100*A*i + 100*B*j
        if w != 0:
            waters.add(w)
waters = list(waters)
waters.sort()


sugars = set()
# Cを何回入れるか
for i in range(F//C + 1):
    # Dを何回いれるか
    for j in range((F - C*i) // D + 1):
        s = i*C + j*D
  
        sugars.add(s)


sugars = list(sugars)
sugars.sort()

# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
water = 0
sugar = 0




for w in waters:
    for s in sugars:
        conc = 0
        # 容量を超えたらアウト
        if w+s > F: break
        # 解けきれない量でもアウト
        if s*100 > w * E: break

        conc = s / (s+w)
        if conc > max_conc:
            max_conc = conc
            water = w
            sugar = s

print(sugar+water, sugar)

Submission status: Wrong Answer

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

waters = set()
for b in range(0, F+1, 100*B):
    for a in range(0, F-b+1, 100*A):
        waters.add(a+b)
waters.remove(0)
waters = list(waters)
waters.sort() 
sugars = set()
for d in range(0, F+1, D):
    for c in range(0, F-d+1, C):
        sugars.add(c+d)
        
sugars = list(sugars)
sugars.sort()

# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
total = 0
sugar = 0

for w in waters:
    for s in sugars:
        conc = 0
        # 容量を超えたらアウト
        if w+s > F: break
        # 解けきれない量でもアウト
        if s*100 > w * E: break

        conc = s / (s+w)
        if conc > max_conc:
            max_conc = conc
            total = s+w
            sugar = s

print(total, sugar)

Submission status: Wrong Answer

Solution code:



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

# 作りうる水の量を洗い出す
waters = set()

for i in range(F//(100*A) + 1):
    for j in range((F-100*A*i)//(100*B) + 1):
        w = 100*A*i + 100*B*j
        if w != 0:
            waters.add(w)


sugars = set()
# Cを何回入れるか
for i in range(F//C + 1):
    # Dを何回いれるか
    for j in range((F - C*i) // D + 1):
        s = i*C + j*D
  
        sugars.add(s)


sugars = list(sugars)
sugars.sort()

# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
total = 0
sugar = 0

for w in waters:
    for s in sugars:
        conc = 0
        # 容量を超えたらアウト
        if w+s > F: break
        # 解けきれない量でもアウト
        if s*100 > w * E: break

        conc = s / (s+w)
        if conc > max_conc:
            max_conc = conc
            total = s+w
            sugar = s

print(total, sugar)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from collections import deque
import math

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

# 作りうる水の量を洗い出す
waters = set()
waters.add(100*A)
if 100*B <= F:
    waters.add(100*B)
q = deque([100*A, 100*B])

while q:
    w = q.popleft()
    # 容器に入れられる量より多いならパス
    if w > F: continue
    for n in [100*A, 100*B]:
        if w + n <= F:
            waters.add(w + n)
            q.append(w + n)

waters = list(waters)
waters.sort()



# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
total = 0
sugar = 0

# それぞれの水量についてなるべく多く砂糖を入れてみる
for w in waters:
    # 砂糖の解けることができる量
    limit = math.floor(w * Fraction(E,100))
    # 全体でFまでしか入らないので、F-wとlimitの小さいほうまでしか追加できない
    limit = min(limit, F - w)
    # Cをi回、Dをj回追加する
    max_sugar = 0
    for i in range(limit // C + 1):
        tmp = C * i + ((limit - C*i) // D) * D
        
        max_sugar = max(max_sugar, tmp)
    if max_conc < Fraction(max_sugar, (w+max_sugar)):
        max_conc = Fraction(max_sugar, (w+max_sugar))
        total = w+max_sugar
        sugar = max_sugar

print(total, sugar)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

import math

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

# 作りうる水の量を洗い出す
waters = set()

for i in range(F//(100*A) + 1):
    for j in range((F-100*A*i)//(200*B) + 1):
        w = 100*A*i + 200*B*j
        if w != 0:
            waters.add(w)


sugars = set()
# Cを何回入れるか
for i in range(F//C + 1):
    # Dを何回いれるか
    for j in range((F - C*i) // D + 1):
        s = i*C + j*D
  
        sugars.add(s)


sugars = list(sugars)
sugars.sort()

# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
total = 0
sugar = 0

for w in waters:
    for s in sugars:
        conc = 0
        # 容量を超えたらアウト
        if w+s > F: break
        # 解けきれない量でもアウト
        if s > w * Fraction(E,100): break

        conc = Fraction(s, s+w)
        if conc > max_conc:
            max_conc = conc
            total = s+w
            sugar = s

print(total, sugar)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from collections import deque
import math

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

# 作りうる水の量を洗い出す
waters = set()
waters.add(100*A)
if 200*B <= F:
    waters.add(200*B)
q = deque([100*A, 200*B])

while q:
    w = q.popleft()
    # 容器に入れられる量より多いならパス
    if w > F: continue
    for n in [100*A, 200*B]:
        if w + n <= F:
            waters.add(w + n)
            q.append(w + n)

waters = list(waters)
waters.sort()

# 砂糖もFまでなのでとりうる量作れるやん
sugars = set()
# Cを何回入れるか
for i in range(F//C + 1):
    # Dを何回いれるか
    for j in range((F - C*i) // D + 1):
        s = i*C + j*D
        if s != 0:
            sugars.add(s)


sugars = list(sugars)
sugars.sort()

# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
total = 0
sugar = 0

for w in waters:
    for s in sugars:
        conc = 0
        # 容量を超えたらアウト
        if w+s > F: break
        # 解けきれない量でもアウト
        if s > w * Fraction(E,100): break

        conc = Fraction(s, s+w)
        if conc > max_conc:
            max_conc = conc
            total = s+w
            sugar = s

print(total, sugar)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from collections import deque
import math

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

# 作りうる水の量を洗い出す
waters = set()
waters.add(100*A)
if 200*B <= F:
    waters.add(200*B)
q = deque([100*A, 200*B])

while q:
    w = q.popleft()
    # 容器に入れられる量より多いならパス
    if w > F: continue
    for n in [100*A, 200*B]:
        if w + n <= F:
            waters.add(w + n)
            q.append(w + n)

waters = list(waters)
waters.sort()



# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
total = 0
sugar = 0

# それぞれの水量についてなるべく多く砂糖を入れてみる
for w in waters:
    # 砂糖の解けることができる量
    limit = math.floor(w * Fraction(E,100))
    # 全体でFまでしか入らないので、F-wとlimitの小さいほうまでしか追加できない
    limit = min(limit, F - w)
    # Cをi回、Dをj回追加する
    max_sugar = 0
    for i in range(limit // C + 1):
        tmp = C * i + ((limit - C*i) // D) * D
        
        max_sugar = max(max_sugar, tmp)
    if max_conc < Fraction(max_sugar, (w+max_sugar)):
        max_conc = Fraction(max_sugar, (w+max_sugar))
        total = w+max_sugar
        sugar = max_sugar

print(total, sugar)

Submission status: Wrong Answer

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

W = [0] * 31
S = [0] * (3001)

W[A], W[B] = 1, 1
for i in range(31):
  if W[i]:
    if i + A < 31:
      W[i + A] = 1
    if i + B < 31:
      W[i + B] = 1
#print("W:", W)

S[0] = 1
for i in range(3001):
  if S[i]:
    if i + C < 3001:
      S[i + C] = 1
    if i + D < 3001:
      S[i + D] = 1
#print("S:", S[:30])

P_max = -1
answer = [0, 0]
for i, w in enumerate(W):
  for j, s in enumerate(S):
    if w != 0:
      ww = i * 100
      s = j
      if ww and ww + s <= F and s / ww * 100 <= E:
        P_tmp = s / (ww + s) * 100
        if P_max < P_tmp:
          P_max = P_tmp
          answer = [ww + s, s]
print(*answer)

Submission status: Wrong Answer

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

W = [0] * 31
S = [0] * (3001)

W[A], W[B] = 1, 1
for i in range(31):
  if W[i]:
    if i + A < 31:
      W[i + A] = 1
    if i + B < 31:
      W[i + B] = 1
#print("W:", W)

S[0] = 1
for i in range(3001):
  if S[i]:
    if i + C < 3001:
      S[i + C] = 1
    if i + D < 3001:
      S[i + D] = 1
#print("S:", S[:30])

P_max = -1
answer = [0, 0]
for i, w in enumerate(W):
  for j, s in enumerate(S):
    if w == 1 and s == 1:
      ww = i * 100
      s = j
      if ww and ww + s <= F and s / ww * 100 <= E:
        P_tmp = s / (ww + s) * 100
        if P_max < P_tmp:
          P_max = P_tmp
          answer = [ww + s, s]
print(*answer)

Submission status: Wrong Answer

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

W = [0] * 31
S = [0] * (3001)

W[A], W[B] = 1, 1
for i in range(31):
  if W[i]:
    if i + A < 31:
      W[i + A] = i + A
    if i + B < 31:
      W[i + B] = i + B
#print("W:", W)

S[0] = 1
for i in range(3001):
  if S[i]:
    if i + C < 3001:
      S[i + C] = i + C
    if i + D < 3001:
      S[i + D] = i + D
#print("S:", S[:30])

P_max = -1
answer = [0, 0]
for w in W:
  for s in S:
    ww = w * 100
    if ww and ww + s <= F and s / ww * 100 <= E:
      P_tmp = s / (ww + s) * 100
      if P_max < P_tmp:
        P_max = P_tmp
        answer = [ww + s, s]
print(*answer)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, C, D, E, F =  MAP()
A *= 100
B *= 100
# 溶ける最大濃度
limit = E / (100+E)

# dp[i][j] := 水i、砂糖jの状態を実施可能か
dp = list2d(F+1, F+1, 0)
dp[0][0] = 1
for i in range(F+1):
    for j in range(F+1):
        # 枝刈り
        if i+j > F:
            continue
        # 実施可能な状態なら、4つの行動を遷移させる
        if dp[i][j]:
            if i+A <= F:
                dp[i+A][j] = 1
            if i+B <= F:
                dp[i+B][j] = 1
            if j+C <= F:
                dp[i][j+C] = 1
            if j+D <= F:
                dp[i][j+D] = 1

ans1 = ans2 = mx = 0
for a in range(F+1):
    for b in range(F+1):
        if a+b > F:
            break
        if a == b == 0:
            continue
        if dp[a][b]:
            x = b / (a+b)
            # 濃度が濃すぎて溶け切らない
            if x > limit:
                continue
            # 最大濃度の更新
            if mx < x:
                mx = x
                ans1 = a + b
                ans2 = b
print(ans1, ans2)

Submission status: Wrong Answer

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

max_concentration = 0
res = (0, 0)
for i in range(0, f//(100*a)+1):
    for j in range(0, (f-100*a*i)//(100*b)+1):
        water = 100 * (a*i + b*j)
        if water == 0:
            continue
        for k in range(0, f-i-j+1):
            for l in range(0, f-i-j-k+1):
                sugar = c*k + d*l
                if water + sugar > f:
                    break
                if sugar > water//100 * e:
                    break
                if water + sugar == 0:
                    continue
                concentration = sugar / (water+sugar)
                if concentration > max_concentration:
                    max_concentration = concentration
                    res = (water+sugar, sugar)

print(*res)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code



a, b, c, d, e, f = map(int, input().split())
x = []
y=[]
quon = 0
noudo = 0

for i in range(1,int(f/a/100)+1):
    for j in range(int(f/b/100)+1):
        if a*100*i + b*100*j <= f:
            x.append(a*100*i + b*100*j)

for i in range(int(f/c)+1):
    for j in range(int(f/d)+1):
        if c*i + d*j <= f:
            y.append(c*i + d*j)


for i in list(set(x)):
    for j in list(set(y)):
        if i + j <= f:
            if j <= i/100 * e :
                if noudo < j:
                    noudo = j
                    quon = i + j


print(quon,noudo)

Submission status: Wrong Answer

Solution code:
abcdef = list(map(int, input().split()))
a, b, c, d, e, f = abcdef[0] * 100, abcdef[1] * 100, abcdef[2], abcdef[3], abcdef[4], abcdef[5]

fa = int(f / a)
fb = int(f / b)
maxc = int(int(f / 100) * e / c)
maxd = int(int(f / 100) * e / d)

res = -1
suger_max = -1
nowden = 0

# 砂糖は水100グラムにEグラム解ける.(max 100)
# a,b,c,dを(i,j,k,l)回入れるとする.i*j < 10^3で k*j < 3000 * 1500くらい…行けるか？
# もう少し工夫要りそう

for i in range(fa + 1):
    for j in range(fb + 1):
        for k in range(maxc + 1):
            for l in range(maxd + 1):
                if i == 0 and j == 0:
                    continue
                wat = a * i + b * j
                sug = c * k + d * l
                if wat + sug > f or sug / wat > e / 100:
                    continue
                else:
                    den = sug / (wat + sug)
                    if (nowden < den):
                        nowden = den
                        res = wat + sug
                        suger_max = sug

print(str(res) + " " + str(suger_max))

Submission status: Wrong Answer

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

water=[]
for i in range(31):
    for j in range(30):
        if (A*i+B*j)*100<=F:
            water.append((A*i+B*j)*100)
sugar=[]
for i in range(501):
    for j in range(500):
        if C*i+D*j<=F//2:
            sugar.append(C*i+D*j)

ans_sum=0
ans_sugar=0
ans_rate=0
for i in water:
    for j in sugar:
        if i==0:
            continue
        if i+j<=F and ans_rate<j/i<=E/100:
            ans_sum=i+j
            ans_sugar=j
            ans_rate=j/i

print(ans_sum,ans_sugar)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
# a = 100 * a(g)の水を入れる
# b = 100 * b(g)の水を入れる
# c = c(g)の砂糖を入れる
# d = d(g)の砂糖を入れる
# e = 100(g)あたりの水に溶ける砂糖
# f = 水の質量と砂糖の質量の合計
# 砂糖水の濃度 = 100 * b / (a + b) (%)
# 答え = 1つ目は求める砂糖水の質量、2つ目はそれに溶けている砂糖の質量

xs = set()
ys = set()

a_limit = f // (100 * a)
for i in range(a_limit + 1):
    b_limit = (f - (100 * a * i)) // (100 * b)
    for j in range(b_limit + 1):
        if i == 0 and j == 0:
            continue
        x = 100 * a * i + 100 * b * j
        xs.add(x)

c_limit = f // c
for i in range(c_limit + 1):
    d_limit = (f - c * i) // d
    for j in range(d_limit + 1):
        y = c * i + d * j
        ys.add(y)

density_limit = e / (100 + e)
max_density = 0.0
w = 0
s = 0
for x in xs:
    for y in ys:
        density = y / (x + y)
        if density_limit >= density and density >= max_density:
            max_density = density
            w = x + y
            s = y

print(w, s)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
# a = 100 * a(g)の水を入れる
# b = 100 * b(g)の水を入れる
# c = c(g)の砂糖を入れる
# d = d(g)の砂糖を入れる
# e = 100(g)あたりの水に溶ける砂糖
# f = 水の質量と砂糖の質量の合計
# 砂糖水の濃度 = 100 * b / (a + b) (%)
# 答え = 1つ目は求める砂糖水の質量、2つ目はそれに溶けている砂糖の質量

xs = set()
ys = set()

a_limit = f // (100 * a)
for i in range(a_limit + 1):
    b_limit = (f - (100 * a * i)) // (100 * b)
    for j in range(b_limit + 1):
        x = 100 * a * i + 100 * b * j
        xs.add(x)

c_limit = f // c
for i in range(c_limit + 1):
    d_limit = (f - c * i) // d
    for j in range(d_limit + 1):
        y = c * i + d * j
        ys.add(y)

density_limit = e / (100 + e)
max_density = 0.0
w = a
s = 0
for x in xs:
    for y in ys:
        if x > 0:
            density = y / (x + y)
            if f >= x + y and density_limit >= density and density > max_density:
                max_density = density
                w = x + y
                s = y

print(w, s)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
# a = 100 * a(g)の水を入れる
# b = 100 * b(g)の水を入れる
# c = c(g)の砂糖を入れる
# d = d(g)の砂糖を入れる
# e = 100(g)あたりの水に溶ける砂糖
# f = 水の質量と砂糖の質量の合計
# 砂糖水の濃度 = 100 * b / (a + b) (%)
# 答え = 1つ目は求める砂糖水の質量、2つ目はそれに溶けている砂糖の質量

xs = set()
ys = set()

a_limit = f // (100 * a)
for i in range(a_limit + 1):
    b_limit = (f - (100 * a * i)) // (100 * b)
    for j in range(b_limit + 1):
        x = 100 * a * i + 100 * b * j
        xs.add(x)

c_limit = f // c
for i in range(c_limit + 1):
    d_limit = (f - c * i) // d
    for j in range(d_limit + 1):
        y = c * i + d * j
        ys.add(y)

density_limit = e / (100 + e)
max_density = 0.0
w = 0
s = 0
for x in xs:
    for y in ys:
        if x > 0:
            density = y / (x + y)
            if f >= x + y and density_limit >= density and density > max_density:
                max_density = density
                w = x + y
                s = y

print(w, s)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
a, b, c, d, e, f = map(int, input().split())
mw = []
for i in range(31):
    for j in range(31):
        mw.append(a * i + b * j)
mw.sort()

ms = []
for i in range(3001):
    for j in range(3001):
        ms.append(- (c * i + d * j))

ms.sort()

ans = 0
ans_mw = mw[1]
ans_ms = 0

for mwi in mw[1:]:
    if mwi * 100 > f:
        break
    msi = -ms[bisect_left(ms, - mwi * e)]
    cand = msi / mwi
    if mwi * 100 + msi <= f and cand > ans:
        ans = cand
        ans_mw = mwi
        ans_ms = msi

print(ans_mw * 100 + ans_ms, ans_ms)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
a, b, c, d, e, f = map(int, input().split())
mw = []
for i in range(31):
    for j in range(31):
        mw.append(a * i + b * j)
mw.sort()

ms = []
for i in range(3001):
    for j in range(3001):
        ms.append(- (c * i + d * j))

ms.sort()

ans = 0
ans_mw = 0
ans_ms = 0

for mwi in mw[1:]:
    if mwi * 100 > f:
        break
    msi = -ms[bisect_left(ms, - mwi * e)]
    cand = msi / mwi
    if mwi * 100 + msi <= f and cand > ans:
        ans = cand
        ans_mw = mwi
        ans_ms = msi

print(ans_mw * 100 + ans_ms, ans_ms)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
a, b, c, d, e, f = map(int, input().split())
mw = []
for i in range(31):
    for j in range(31):
        mw.append(a * i + b * j)
mw.sort()

ms = []
for i in range(3001):
    for j in range(3001):
        ms.append(- (c * i + d * j))

ms.sort()

ans = 0
ans_mw = 0
ans_ms = 0

for mwi in mw[1:]:
    if mwi * 100 > f:
        break
    msi = -ms[bisect_left(ms, - mwi * e)]
    cand = msi / mwi
    if mwi * 100 + msi <= e and cand > ans:
        ans = cand
        ans_mw = mwi
        ans_ms = msi

print(ans_mw * 100 + ans_ms, ans_ms)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
a, b, c, d, e, f = map(int, input().split())
mw = []
for i in range(31):
    for j in range(31):
        mw.append(a * i + b * j)
mw.sort()

ms = []
for i in range(3001):
    for j in range(3001):
        ms.append(- (c * i + d * j))

ms.sort()

ans = 0
ans_mw = 0
ans_ms = 0

for mwi in mw[1:]:
    if mwi * 100 + mwi * e > f:
        break
    msi = -ms[bisect_left(ms, - mwi * e)]
    cand = msi / mwi
    if cand > ans:
        ans = cand
        ans_mw = mwi
        ans_ms = msi

print(ans_mw * 100 + ans_ms, ans_ms)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

#水を100ずつ区切って考える
A, B, C, D, E, F = rl()
water = [False for x in range(F//100 + 1)]
answer = (0, 0, 0)
for i in range(F//(100*B) + 1):
    for j in range(F//(100*A) + 1):
        k = i * B + j * A
        if k > len(water) - 1:
            continue
        water[k] = True
for i in range(len(water)):
    if water[i] == True:
        water[i] = i
for x in water:
    if not x:
        continue
    max = x * E
    for i in range(max//D+1):
        for j in range(max//C+1):
            y = D * i + C * j
            solution = x*100 + y
            if solution > F:
                break
            if y > max:
                break
            elif solution > 0:
                result = y / solution
                if result > answer[0]:
                    answer = (result, solution, y)

print(answer[1], answer[2])

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_sugar = E / (100 + E)
res = 0 
ans = [0, 0]
for a in range(F // 100*A + 1): 
        for b in range(F // 100*B + 1): 
                for c in range(int(F * max_sugar) // C + 1): 
                        for d in range(int(F * max_sugar) // D + 1): 
                                mass = 100*A*a + 100*B*b + C*c + D*d 
                                sugar = C*c + D*d 
                                if 0 < mass <= F and sugar / mass <= max_sugar:
                                        if res < sugar / mass:
                                                res = sugar / mass 
                                                ans = [mass, sugar]
                                else:
                                        break
print(str(ans[0]) + " " + str(ans[1]))

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
max_sugar = E / (100 + E)
res = 0 
ans = [0, 0]
for a in range(F // 100*A + 1): 
        for b in range(F // 100*B + 1): 
                for c in range(int(F * max_sugar) // C + 1): 
                        for d in range(int(F * max_sugar) // D + 1): 
                                mass = 100*A*a + 100*B*b + C*c + D*d 
                                sugar = C*c + D*d 
                                if 0 < mass <= F and sugar / mass <= max_sugar:
                                        if res < sugar / mass:
                                                res = sugar / mass 
                                                ans = [mass, sugar]
print(str(ans[0]) + " " + str(ans[1]))

Submission status: Wrong Answer

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

dp = [0] * (F + 1)
if A < F + 1: dp[A] = 1
if B < F + 1: dp[B] = 1

for i in range(F + 1):
  if dp[i]:
    if i + A < F + 1: dp[i + A] = 1
    if i + B < F + 1: dp[i + B] = 1
#print(dp)

dp2 = [0] * (F + 1)
dp2[0] = 1
dp2[C] = 1
dp2[D] = 1

for i in range(F + 1):
  if dp2[i]:
    if i + C < F + 1: dp2[i + C] = 1
    if i + D < F + 1: dp2[i + D] = 1
#print(dp2)

max_con = 0
answer = [100, 0]
for i in range(0, len(dp)):
  if dp[i]:
    #print(i)
    for j in range(0, len(dp2)):
      if i + j > F or j / (i + j) >= E / (E + 100):
        break
      if dp2[j] and max_con < j / (i + j):
        max_con = j / (i + j)
        answer = [i + j, j]
print(*answer)

Submission status: Wrong Answer

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

dp = [0] * (F + 1)
if A < F + 1: dp[A] = 1
if B < F + 1: dp[B] = 1

for i in range(F + 1):
  if dp[i]:
    if i + A < F + 1: dp[i + A] = 1
    if i + B < F + 1: dp[i + B] = 1
#print(dp)

dp2 = [0] * (F + 1)
dp2[C], dp2[D] = 1, 1

for i in range(F + 1):
  if dp2[i]:
    if i + C < F + 1: dp2[i + C] = 1
    if i + D < F + 1: dp2[i + D] = 1
#print(dp2)

max_con = 0
answer = [100, 0]
for i in range(1, len(dp)):
  if dp[i]:
    #print(i)
    for j in range(1, len(dp2)):
      if i + j > F or j / (i + j) >= E / (E + 100):
        break
      if dp2[j] and max_con < j / (i + j):
        max_con = j / (i + j)
        answer = [i + j, j]
print(*answer)

Submission status: Wrong Answer

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

dp = [0] * (F + 1)
if A < F + 1: dp[A] = 1
if B < F + 1: dp[B] = 1

for i in range(F + 1):
  if dp[i]:
    if i + A < F + 1: dp[i + A] = 1
    if i + B < F + 1: dp[i + B] = 1
#print(dp)

dp2 = [0] * (F + 1)
dp2[C], dp2[D] = 1, 1

for i in range(F + 1):
  if dp2[i]:
    if i + C < F + 1: dp2[i + C] = 1
    if i + D < F + 1: dp2[i + D] = 1
#print(dp2)

max_con = 0
answer = [0, 0]
for i in range(1, len(dp)):
  if dp[i]:
    #print(i)
    for j in range(1, len(dp2)):
      if i + j > F or j / (i + j) > E / (E + 100):
        break
      if dp2[j] and max_con < j / (i + j):
        max_con = j / (i + j)
        answer = [i + j, j]
print(*answer)

Submission status: Wrong Answer

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

dp = [0] * (F//100 + 1)
dp[A] = 1
if B < F//100 + 1: dp[B] = 1

for i in range(F//100 + 1):
  if dp[i]:
    if i + A < F//100 + 1: dp[i+A] = 1
    if i + B < F//100 + 1: dp[i+B] = 1
#print(dp)

dp2 = [0] * (F + 1)
dp2[C],dp2[D] = 1,1

for i in range(F + 1):
  if dp2[i]:
    if i + C < F + 1: dp2[i+C] = 1
    if i + D < F + 1: dp2[i+D] = 1
#print(dp2)

max_con = 0
answer = [0,0]
for i in range(1,len(dp)):
  if dp[i]:
    #print(i)
    for j in range(1,len(dp2)):
      
      if i*100 + j > F or j*100 / (i*100 + j) > E*100 / (E + 100):
        break
      if dp2[j] and max_con <= j*100 / (i*100 + j):
        max_con = j*100 / (i*100 + j)
        answer = [i*100 + j, j]
print(*answer)

Submission status: Wrong Answer

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

dp = [0] * (F//100 + 1)
dp[A] = 1
if B < F//100 + 1: dp[B] = 1

for i in range(F//100 + 1):
  if dp[i]:
    if i + A < F//100 + 1: dp[i+A] = 1
    if i + B < F//100 + 1: dp[i+B] = 1
#print(dp)

dp2 = [0] * (F + 1)
dp2[C],dp2[D] = 1,1

for i in range(F + 1):
  if dp2[i]:
    if i + C < F + 1: dp2[i+C] = 1
    if i + D < F + 1: dp2[i+D] = 1
#print(dp2)

max_con = 0
answer = [0,0]
for i in range(1,len(dp)):
  if dp[i]:
    #print(i)
    for j in range(1,len(dp2)):
      
      if i*100 + j > F or j*100 / (i*100 + j) > E*100 / (E + 100):
        break
      if dp2[j] and max_con < j*100 / (i*100 + j):
        max_con = j*100 / (i*100 + j)
        answer = [i*100 + j, j]
print(*answer)

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
#show_flg=True

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

m=0
ans=(0,0)
for a in range(31):
    for b in range(16):
        for c in range(101):
            for d in range(101):
                if a*A*100+b*B*100+c*C+d*D<=F and (a*A+b*B)*E>=c*C+d*D and a+b>0:
                    if m<(c*C+d*D)/(a*A+b*B):
                        m=(c*C+d*D)/(a*A+b*B)
                        ans=(100*(a*A+b*B)+c*C+d*D,c*C+d*D)

print(*ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
#show_flg=True

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

m=0
ans=(A*100,A*100)
for a in range(31):
    for b in range(16):
        for c in range(101):
            for d in range(101):
                if a*A*100+b*B*100+c*C+d*D<=F and (a*A+b*B)*E>=c*C+d*D and a+b>0:
                    if m<(c*C+d*D)/(a*A+b*B):
                        m=(c*C+d*D)/(a*A+b*B)
                        ans=(100*(a*A+b*B)+c*C+d*D,c*C+d*D)

print(*ans)