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: Runtime Error

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


def concentration(water, suger):
    if water * E/100 < suger or water + suger == 0:
        return 0
    return (100 * suger/(water + suger))

lst_w = []
limit_w = (F+A*100-1)//(A*100)
for i in range(limit_w):
    for j in range(limit_w):
        if 100 * (A * i + B * j) <= F:
            lst_w += [100 * (A * i + B * j)]

lst_s = []
limit_s = (F+C-1)//C
for i in range(limit_s):
    for j in range(limit_s):
        if C* i + D * j <= F:
            lst_s += [C * i + D * j]

# print (lst_w)
# print (lst_s)
set_w = set(lst_w)
set_s = set(lst_s)

# print (set_w)
# print (set_s)

ans = 0
ans_total = 0
ans_suger = 0
for water in set_w:
    for suger in set_s:
        if water + suger <= F:
            a = concentration(water, suger)
            if ans < a:
                ans = a
                ans_total = water + suger
                ans_suger = suger
            if ans == 50:
                print (ans_total, ans_suger)
                sys.exit()

if ans = 0:
    print (A * 100, 0)
else:
    print (ans_total, ans_suger)

# print (ans)

Submission status: Runtime Error

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


def concentration(water, suger):
    if water * E/100 < suger or water + suger == 0:
        return 0
    return (100 * suger/(water + suger))

lst_w = []
limit_w = (F+A*100-1)//(A*100)
for i in range(limit_w):
    for j in range(limit_w):
        if 100 * (A * i + B * j) <= F:
            lst_w += [100 * (A * i + B * j)]

lst_s = []
limit_s = (F+C-1)//C
for i in range(limit_s):
    for j in range(limit_s):
        if C* i + D * j <= F:
            lst_s += [C * i + D * j]

# print (lst_w)
# print (lst_s)
set_w = set(lst_w)
set_s = set(lst_s)

# print (set_w)
# print (set_s)

ans = 0
for water in set_w:
    for suger in set_s:
        if water + suger <= F:
            a = concentration(water, suger)
            if ans < a:
                ans = a
                ans_total = water + suger
                ans_suger = suger

# print (ans)
print (ans_total, ans_suger)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
ans=(0,0,0)
F+=1
E=100*E/(100+E)
for a in range(0,F,A*100):
	for b in range(0,F-a,B*100):
		for c in range(0,F-a-b,C):
          	if a==0 and b==0:break
			for d in range(0,F-a-b-c,D):
				s=a+b+c+d
				e=100*(c+d)/s
				if ans[2]< e <= E:
					ans=(s,c+d,e)
				elif e>E:break
print(ans[0],ans[1])

Submission status: Runtime Error

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


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    mn = 0
    ret = None
    for a in range((F // 100) // A + 1):
        for b in range(((F // 100) - a * A) // B + 1):
            w = a * A + b * B
            if w < 1:
                continue
            for c in range(E * w // C + 1):
                for d in range((E * w - c * C) // D + 1):
                    s = (c * C + d * D)
                    r = s / w
                    if w * 100 + s <= F and r <= E and r > mn:
                        mn = r
                        ret = (w * 100 + s, s)
    print(ret[0], ret[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: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water = []
sugar = []
for i in range(1+F//A):
    for j in range(1+F//B):
        if i * A + j * B <= F:
            water.append(i * A + j * B)
for i in range(1+F//C):
    for j in range(1+F//D):
        if i * C + j * D <= F:
            sugar.append(i * C + j * D)
max_sugar_percent = 0
max_sugar_water = 0
max_sugar = 0
water.sort()
sugar.sort()
for i in water:
    for j in sugar:
        if i + j > F:
            break
        if j > E * i / 100:
            break
        sugar_percent = i and (100 * s) / (i + j)
        if sugar_percent >= max_sugar_percent:
            sugar_percent = max_sugar_percent
            max_sugar = j
            max_sugar_water = i + j
print(max_sugar_water, max_sugar)

Submission status: Runtime Error

Solution code:
import sys
#input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))
A, B, C, D, E, F = inpl()
waters = [100*A*a + 100*B*b for a in range(30//A + 1) for b in range((30-A*a)//B + 1)]
sugars = [C*c + D*d for c in range(3000//C + 1) for d in range((3000-C*c)//D + 1)]

waters = sorted(set(waters))[1:]
sugars = sorted(set(sugars))


def check(m):
    if m > E:
        return False, None, None
    for water in waters:
        sugar_ix = bisect_left(sugars, m*water/(100-m))
        if (sugar_ix == len(sugars)):
            continue
        sugar = sugars[sugar_ix]
        if sugar + water <= F and sugar <= water*E//100:
            return True, sugar, water
    else:
        return False, None, None

OK = 0
NG = E + 1

while abs(OK - NG)>1e-8:
    mid = (OK+NG)/2
    if check(mid)[0]:
        OK = mid
    else:
        NG = mid

_, sugar, water = check(OK)
print(sugar+water, sugar)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
ans = 0
for i in range(f//(a*100)+1):
  for j in range((f-a*100*i)//(b*100)+1):
    for k in range((f-a*i*100-b*j*100)//c+1):
      for l in range((f-a*i*100-b*j*100-c*k)//d+1):
        w = i+j
        s = k+l
        if w*e >= k:
          ans = max(ans,s/(w*100+s))
print(ans)

Submission status: Runtime Error

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

x = []
y = []
ans_max = 0
ans = []

for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*(A*i+B*j)
        if(water<=F and not water in x):
            x.append(water)

for i in range(F):
    for j in range(F):
        salt = C*i+D*j
        if(salt<=F and not salt in y):
            y.append(salt)

for i in x:
    for j in y:
        if(i==0):
            continue
        elif(100*j <= i*E and i+j <= F):
            percent = 100*j/(i+j)
            if(ans_max < percent):
                ans_max = percent
                ans = [i,j]

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

Submission status: Runtime Error

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

x = []
y = []
ans_max = 0
ans = []

for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*(A*i+B*j)
        if(water<=F and not water in x):
            x.append(water)

for i in range(F):
    for j in range(F):
        salt = C*i+D*j
        if(salt<=F and not salt in y):
            y.append(salt)

for i in x:
    for j in y:
        if(i==0):
            break
        elif(100*j <= i*E and i+j <= F):
            percent = 100*j/(i+j)
            if(ans_max < percent):
                ans_max = percent
                ans = [i,j]

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

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = [int(x) for x in input().split()]
#%%
x = []
y = []
ans_max = 0
ans = []

for i in range(F//(100*A)+1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*(A*i+B*j)
        if(water<=F and not water in x):
            x.append(water)

for i in range(F):
    for j in range(F):
        salt = C*i+D*j
        if(salt<=F and not salt in y):
            y.append(salt)

for i in x:
    for j in y:
        if(i==0):
            break
        elif(100*j < i*E and i+j <= F):
            percent = 100*j/(i+j)
            if(ans_max < percent):
                ans_max = percent
                ans = [i,j]

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

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
density = 0
for water_a in range(0,3001,a * 100):
    for water_b in range(0,3001,b * 100):
        if water_a + water_b > f:
            break
        for suger_c in range(0,3001,c):
            if water_a + water_b + suger_c > f:
                break
            for suger_d in range(0,3001,d):
                if water_a + water_b + suger_c + suger_d > f:
                    break
                if e * (water_a + water_b) - 100 * (suger_c + suger_d) < 0:
                    break
                water = water_a + water_b
                suger = suger_c + suger_d
                if water + suger == 0:
                    break
                if 1 >= suger / (water + suger) > density:
                    sugerwater = water + suger
                    meltsuger = suger
                    density = suger / (water + suger)
print(sugerwater, meltsuger)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F =  map(int, input().split())
M = 0
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:
			break
		for k in range((F - w) // C + 1):
			for l in range((F - w - C * k) // D + 1):
				s = C * k + D * l
				if E >= 100 * s / w and 100 * s / w > M:
					M = 100 * s / w
					X = [w + s, s]
print(X[0], X[1])

Submission status: Runtime Error

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

dens=0
for a in range(30+1):
  for b in range(30+1):
    waterA=100*a*A
    waterAB=waterA+100*b*B
    if  waterA<= F and 0 < waterAB <= F:
      for c in range(100+1):
        for d in range(100+1):
          if waterAB+c*C+d*D <= F:
            if c*C+d*D <= (a*A+b*B)*E:
              if dens < (c*C+d*D)/(waterAB+c*C+d*D):
                dens=(c*C+d*D)/(waterAB+c*C+d*D)
                max=waterAB+c*C+d*D
              
print(max,int(max*dens))

Submission status: Runtime Error

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

dens=0
for a in range(30+1):
  for b in range(30+1):
    waterA=100*a*A
    waterAB=waterA+100*b*B
    if  waterA<= F and 0 < waterAB <= F:
      for c in range(100+1):
        for d in range(100+1):
          if waterAB+c*C+d*D <= F and c*C+d*D <= (a*A+b*B)*E:
            if dens < (c*C+d*D)/(waterAB+c*C+d*D):
              dens=(c*C+d*D)/(waterAB+c*C+d*D)
              max1=waterAB+c*C+d*D
              max2=c*C+d*D
              
print(max1,max2)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
con = 0
sugar = 0
for a in range(int(F / 100 / A) + 1):
    for b in range(int((F - a * 100 * A)/ 100 / B) + 1):
        if not a == b == 0:
            for c in range(int((a*A+b*B)*E/C)+1):
                for d in range(int(((a*A+b*B)*E-c*C)/D)+1):
                    if 100*(A*a+B*b)+C*c+D*d <= F:
                        if con < 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D)):
                            con = 100*((c*C+d*D)/(100*a*A+100*b*B+c*C+d*D))
                            sugar = c*C+d*D
                            water = 100*a*A+100*b*B+c*C+d*D
print(water, sugar)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

"""解説
https://www.youtube.com/watch?v=nCHz87GMdpo



"""

def solve2():
    """ 全探索O(F**2) """
    A, B, C, D, E, F = list(map(int, input().split()))

    # 水をx, 砂糖をyとする
    sugars = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            y = i*C + j*D
            if y <= F:
                # 作れる砂糖の量y[g]をメモする
                sugars.append(y)

    water = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            x = 100*A*i + 100*B*j
            if x <= F:
                # 作れる水の量x[g]をメモする
                water.append(x)
    
    sugars.sort()
    water.sort()
    
    # 濃度
    concent = 0
    for x in water:
        for y in sugars:
            if x+y > F:
                break
            if x+y > 0 and y/(x+y) <= E/(100+E):
                if y/(x+y) >= concent:
                    concent = y/(x+y)
                    ans = f"{x+y} {y}"
    print(ans)


def solve():
    """ WA """
    A, B, C, D, E, F = list(map(int, input().split()))

    # dp[i] := 砂糖水i[g]のときに作れる最大の濃度
    # 配るDP
    dp= [0]*(F+1)

    for i in range(0, F+1):
        if i+100*A <= F:
            concent = (dp[i]*i)/(i+100*A)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*A] = max(dp[i+100*A], concent)
        if i+100*B <= F:
            concent = (dp[i]*i)/(i+100*B)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*B] = max(dp[i+100*B], concent)
        if i+C <= F:
            concent = (dp[i]*i+C)/(i+C)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+C] = max(dp[i+C], concent)
        if i+D <= F:
            concent = (dp[i]*i+D)/(i+D)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+D] = max(dp[i+D], concent)
    
    print(dp)
    return
    max_concent = max(dp)
    print(dp.index(max_concent), round(dp.index(max_concent)*max_concent))



if __name__ == "__main__":
    solve2()

Submission status: Runtime Error

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

"""解説
https://www.youtube.com/watch?v=nCHz87GMdpo



"""

def solve2():
    """ 全探索O(F**2) """
    A, B, C, D, E, F = list(map(int, input().split()))

    # 水をx, 砂糖をyとする
    sugars = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            y = i*C + j*D
            if y <= F:
                # 作れる砂糖の量y[g]をメモする
                sugars.append(y)

    water = []
    for i in range(0, F+1):
        for j in range(0, F+1):
            x = 100*A*i + 100*B*j
            if x <= F:
                # 作れる水の量x[g]をメモする
                water.append(x)
    
    # 濃度
    concent = 0
    for x in water:
        for y in sugars:
            if x+y <= F and x+y > 0 and y/(x+y) <= E/(100+E):
                if y/(x+y) >= concent:
                    concent = y/(x+y)
                    ans = f"{x+y} {y}"
    print(ans)


def solve():
    """ WA """
    A, B, C, D, E, F = list(map(int, input().split()))

    # dp[i] := 砂糖水i[g]のときに作れる最大の濃度
    # 配るDP
    dp= [0]*(F+1)

    for i in range(0, F+1):
        if i+100*A <= F:
            concent = (dp[i]*i)/(i+100*A)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*A] = max(dp[i+100*A], concent)
        if i+100*B <= F:
            concent = (dp[i]*i)/(i+100*B)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+100*B] = max(dp[i+100*B], concent)
        if i+C <= F:
            concent = (dp[i]*i+C)/(i+C)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+C] = max(dp[i+C], concent)
        if i+D <= F:
            concent = (dp[i]*i+D)/(i+D)
            concent = concent if concent <= E/(100+E) else 0
            dp[i+D] = max(dp[i+D], concent)
    
    print(dp)
    return
    max_concent = max(dp)
    print(dp.index(max_concent), round(dp.index(max_concent)*max_concent))



if __name__ == "__main__":
    solve2()

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = map(int,input().split())
ans = [0,0]
M = 0
for a in range(31):
    if F < a*A*100:
        break
    for b in range(31-a):
        if a == 0 and b == 0:
            continue
        W = (a*A+b*B)*100
        if F < W:
            break
        CD_max = min((E * W) // 100,F-W)
        for c in range(CD_max//C+1):
            d = max(0,(CD_max-c*C)//D)
            CD = c*C+d*D
            con = CD/(W+CD)
            if con > M:
                M = con
                ans = [str(W+CD),str(CD)]
print(" ".join(ans))

Submission status: Runtime Error

Solution code:

import math

def read_input():
    a, b, c, d, e, f = map(int, input().split())
    return a, b, c, d, e, f


# 100aと100bの線形結合でf以下でとりうる値を見つける
def search_water_valiation(a, b, f):
    result = []
    for i in range(30):
        for j in range(30):
            water = 100*a*i + 100*b*j
            if water <= f:
                result.append(water)

    result = list(set(result))
    result.sort()

    return result


# c, dの線形結合でmax_sugar以下の最大値を探す
# cx + dy <= max_sugarより
# y <= - c/d x + max_sugar/d
# xの範囲は(0, max_sugar/c)
def search_most_sweet(c, d, max_sugar):
    sugars = []
    for x in range(math.floor(max_sugar/c) + 1):
        y = math.floor((-c * x + max_sugar)/d)
        sugars.append(c*x + d*y)

    sugars = list(set(sugars))
    return max(sugars)

def submit():
    a, b, c, d, e, f = read_input()

    waters = search_water_valiation(a, b, f)
    max_sugars = [w * e // 100 for w in waters]

    result = []
    for water, max_sugar in zip(waters, max_sugars):
        sugar = search_most_sweet(c, d, max_sugar)
        result.append((water, sugar))

    result = [r for r in result if r[0] + r[1] <= f]
    result = [(w+s, s, 100 * s / (w + s)) for (w, s) in result if (w, s) != (0, 0)]

    r = max(result, key=lambda x:x[2])
    print('{} {}'.format(r[0], r[1]))

if __name__ == '__main__':
    submit()

Submission status: Runtime Error

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

AQ = set()
for i in range(F):
    for j in range(F):
        if 100*A*i + 100*B*j <= F:
            AQ.add(100*A*i + 100*B*j)
        else:
            break

SG = set()
for i in range(F):
    for j in range(F):
        if C*i + D*j <= F:
            SG.add(C*i + D*j)
        else:
            break

ans = [0, 0]
maxc = None
for aq in AQ:
    for sg in SG:
        if aq == 0:
            continue
        if aq+sg > F or sg/aq > E/100:
            continue
        if maxc < sg/(aq+sg):
            ans = [aq, sg]
            maxc = sg/(aq+sg)
if maxc is None:
    print(0, 0)
else:
    print(ans[0]+ans[1], ans[1])

Submission status: Runtime Error

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

per = 0
ans = []

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        w = i * a * 100 + j * b * 100
        if w > f or w == 0:
            break
        for k in range((e * w//100)//c + 1):
            for l in range((e * w//100)//d + 1):
                if e * w//100 < c * k + d * l or w + c * k + d * l > f:
                    break
                now = 100 * (c*k+d*l) / (w+c*k+d*l)
                if per < now:
                    per = now
                    ans = [w+c*k+d*l, c*k+d*l]
if ans = []:
    print(100*a, 0)
else:
    print(ans[0], ans[1])

Submission status: Runtime Error

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

per = 0
ans = []

for i in range(f//(100*a) + 1):
    for j in range(f//(100*b) + 1):
        w = i * a * 100 + j * b * 100
        if w > f or w == 0:
            break
        for k in range((e * w//100)//c + 1):
            for l in range((e * w//100)//d + 1):
                if e * w//100 < c * k + d * l or w + c * k + d * l > f:
                    break
                now = 100 * (c*k+d*l) / (w+c*k+d*l)
                if per < now:
                    per = now
                    ans = [w+c*k+d*l, c*k+d*l]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
q=[[0,0]]
k=0
ans=0
while len(q)>0:
  x,y=q.pop()
  if x!=0 and y/(x+y)>k:
    k=y/(x+y)
    ans=[x,y]
  if x+y+100*a<=f:
    q+=[[x+100*a,y]]
  if x+y+100*b<=f:
    q+=[[x+100*b,y]]
  if y+c<=(x-y)*e/100 and x+y+c<=f:
    q+=[[x+c,y+c]]
  if y+d<=(x-y)*e/100 and x+y+d<=f:
    q+=[[x+d,y+d]]
print(ans[0],ans[1])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
q=[[0,0]]
k=0
ans=0
while len(q)>0:
  x,y=q.pop()
  if x/(x+y)>k:
    k=x/(x+y)
    ans=[x,y]
  if x+y+100*a<=f:
    q+=[[x+100*a,y]]
  if x+y+100*b<=f:
    q+=[[x+100*b,y]]
  if y+c<=(x-y)*e/100 and x+y+c<=f:
    q+=[[x+c,y+c]]
  if y+d<=(x-y)*e/100 and x+y+d<=f:
    q+=[[x+d,y+d]]
print(ans[0],ans[1])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
q=[[0,0]]
ans=0
while len(q)>0:
  x,y=pop(q)
  if x+y+100*a<=f:
    q+=[[x+100*a,y]]
  if x+y+100*b<=f:
    q+=[[x+100*b,y]]
  if y+c<=(x-y)*e/100 and x+y+c<=f:
    q+=[[x+c,y+c]]
    ans=max(ans,100*(y+c)/(x+y+c))
  if y+d<=(x-y)*e/100 and x+y+d<=f:
    q+=[[x+d,y+d]]
    ans=max(ans,100*(y+d)/(x+y+d))
print(ans)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
q=[[0,0]]
ans=0
while len(q)>0:
  x,y=pop(q)
  if x+y+100*a<=f:
    q.append([x+100*a,y])
  if x+y+100*b<=f:
    q.append([x+100*b,y])
  if y+c<=(x-y)*e/100 and x+y+c<=f:
    q.append([x+c,y+c])
    ans=max(ans,100*(y+c)/(x+y+c))
  if y+d<=(x-y)*e/100 and x+y+d<=f:
    q.append([x+d,y+d])
    ans=max(ans,100*(y+d)/(x+y+d))
print(ans)

Submission status: Runtime Error

Solution code:
def solve(a, b, c, d, e, f):
    S = set()
    for x in range(0, f, 100*a):
        for y in range(0, f, 100*b):
            z = x + y
            if 0 < z <= f:
                S.add(z)
    T = set()
    for x in range(0, f, c):
        for y in range(0, f, d):
            z = x + y
            if z <= f:
                T.add(z)
    threshold = e / (100 + e)
    best = 0
    solution = None
    for x in S:
        for y in T:
            z = x + y
            cur = y / z
            if (best < cur <= threshold) and (z <= f):
                best = cur
                solution = (z, y)
    return "%d %d" % solution

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

Submission status: Runtime Error

Solution code:
import bisect
a, b, c, d, e, f = [int(item) for item in input().split()]

water = set()
for i in range(31):
    for j in range(31):
        w = i*a + j*b 
        if w <= f // 100:
            water.add(w)
sugar = set()
for i in range(1501):
    j = 0
    while i*c + j*d <= 1500:
        sugar.add(i*c + j*d)
        j += 1
sugar = sorted(sugar)
ans = []
for w in water:
    sid = bisect.bisect_left(sugar, w*e)
    while sugar[sid] + w*100 > f:
        sid -= 1
    if w != 0:
        total = w*100 + sugar[sid]
        ans.append([sugar[sid]/total, total, sugar[sid]])
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])

Submission status: Runtime Error

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

sugars = set()
waters = set()
for i in range(F):
    for j in range(F):
        w = 100 * A * j + 100 * B * i
        if w > max_water:
            break
        if i + j != 0 and w <= max_water:
            waters.add(w)
            
for i in range(F):
    for j in range(F):
        s = C * j + D * i
        if s > max_sugar:
            break
        if i + j != 0 and s <= max_sugar:
            sugars.add(s)


sugar_waters = []
for water in waters:
    for sugar in sugars:
        sugar_water = water + sugar
        noudo = int(sugar / water)
        if sugar_water <= F and noudo <= int(E / 100):
            sugar_waters.append([sugar_water, sugar])

ans = max(sugar_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

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

sugars = set()
waters = set()
for i in range(F):
    for j in range(F):
        w = 100 * A * j + 100 * B * i
        if w > max_water:
            break
        if i + j != 0 and w <= max_water:
            waters.add(w)

for i in range(F):
    for j in range(F):
        s = C * j + D * i
        if s > max_sugar:
            break
        if i + j != 0 and s <= max_sugar:
            sugars.add(s)


sugar_waters = []
for water in waters:
    for sugar in sugars:
        sugar_water = water + sugar
        noudo = sugar / water
        if sugar_water <= F and noudo <= (E / 100):
            sugar_waters.append([sugar_water, sugar])

ans = max(sugar_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))

Submission status: Runtime Error

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

sugars = set()
waters = set()
a = int(F / 100)
for i in range(a):
    for j in range(a):
        w = 100 * A * j + 100 * B * i
        if w > max_water:
            break
        if i + j != 0 and w <= max_water:
            waters.add(w)

for i in range(F):
    for j in range(F):
        s = C * j + D * i
        if s > max_sugar:
            break
        if i + j != 0 and s <= max_sugar:
            sugars.add(s)


sugar_waters = []
for water in waters:
    for sugar in sugars:
        sugar_water = water + sugar
        noudo = sugar / water
        if sugar_water <= F and noudo <= (E / 100):
            sugar_waters.append([sugar_water, sugar])

ans = max(sugar_waters, key=lambda x: x[1] / x[0])
print(' '.join(map(str, ans)))