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:
A,B,C,D,E,F = map(int,input().split())
M = []
S = []

# 100A,100B の水
for a in range(1 + F // 100):
    for b in range(1 + F // 100):
        if 100 * (a * A + b * B) <= F:
            M.append(100 * (a * A + b * B))

# c,d の砂糖
for c in range(1 + F // C):
    for d in range(1 + F // D):
        if c * C + d * D <= F:
            S.append(c * C + d * D)

M=list(set(M))
S=list(set(S))
M.sort()
S.sort()

x = 0
for m in M:
  for s in S:
    if m != 0 and s != 0 and m + s <= F:
        sol = 100 * s / m
        if sol > x and sol <= E:
            x = sol
            X, Y = m + s, s

print(X,Y)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = map(int,input().split())
M = []
S = []
 
for a in range(1+F//100):
    for b in range(1+F//100):
        if 100*(a*A+b*B)<=F:
            M.append(100*(a*A+b*B))

for c in range(1+F//C):
    for d in range(1+F//D):
        if c*C+d*D<=F:
            S.append(c*C+d*D)

M=list(set(M))
S=list(set(S))
M.sort()
S.sort()
#print(M,S)

x = 0
for m in M:
  for s in S:
    if m != 0 and s != 0 and m+s <= F:
      sol = 100 * s / m
      if sol > x and sol <= E:
        x = sol
        X,Y = m+s,s
      
print(X,Y)

Submission status: Runtime Error

Solution code:
import math
a,b,c,d,e,f = map(int,input().split())
max_sugar = f*e*100/(100+e)
box = {}
for i in range(31):
  for j in range(31):
    water = 100*a*i + 100*b*j
    if water > f:
      break
    sugar_range = int(math.ceil(max_sugar/c))
    for k in range(sugar_range):
      for l in range(sugar_range):
        sugar = c*k + d*l
        if sugar > max_sugar:
          break
        amount = water + sugar
        if amount > f or amount == 0
          break
        conc = 100*sugar / amount
        if conc <= e*100/(100+e):
          box[conc] = [amount,sugar]
answer = max(box.items(),key = lambda x:x[0])[1]
print(str(answer[0]) + " " +str(answer[1]))

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {}
dp[a][0] = a
if b <= f:
    dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {}
dp[a][0] = a
dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
conc=0
for a in range(0, F+1, A*100):
    for b in range(0, F-A+1, B*100):
        water=a+b
        if water == 0 or water > F:
            continue
        for c in range(0, F-water+1, C):
            for d in range(0, F-water-c+1, D):
                sugar=c+d
                if sugar==0:
                    continue
                total=water+sugar
                if sugar > water/100*E:
                    continue
                if sugar/total > conc:
                    conc = sugar/total
                    res=[total,sugar]
print(res[0],res[1])

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
conc=0
for a in range(0, F+1, A*100):
    for b in range(0, F-A+1, B*100):
        water=a+b
        if water == 0 or water > F:
            continue
        for c in range(0, F-water+1, C):
            for d in range(0, F-water-c+1, D):
                sugar=c+d
                total=water+sugar
                if sugar > water/100*E:
                    continue
                if sugar/total > conc:
                    conc = sugar/total
                    res=[total,sugar]
print(res[0],res[1])

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
def cal_cons():
    disc=False
    for a in range(31):
        for b in range(31):
            water=a*A*100+b*B*100
            if water > F or water==0:
                break
            for c in range(3001):
                for d in range(3001):
                    suger=c*C+d*D
                    if suger==0:
                        break
                    total=water+suger
                    if water+suger>F:
                        break
                    if suger > water/100*E:
                        break
                    yield total,suger,100*suger/(water+suger)
                    disc=True
    else:
        if disc:
            yield water,0,0
total,suger,cons=max(list(cal_cons()),key=lambda x:x[2])
print(total,suger)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
def cal_cons():
    for a in range(0,31,A):
        for b in range(0,31,B):
            for c in range(0,101,C):
                for d in range(0,101,D):
                    w=a*100+b*100
                    s=c+d
                    if w==0 or s==0:
                        break
                    if w+s>F:
                        break
                    if w/100*E < s:
                        break
                    yield w+s,s,100*s/(w+s)

f,s,c=max(list(cal_cons()),key=lambda x:x[2])
print(f,s)

Submission status: Runtime Error

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

def cal_cons():
    for a in range(0,3100,A*100):
        for b in range(0,3100,B*100):
            for c in range(0,31,C):
                for d in range(0,31,D):
                    w=a+b
                    s=c+d
                    if w==0 or s==0:
                        break
                    if w+s>F:
                        break
                    if w/100*E < s:
                        break
                    yield w+s,s,100*s/(w+s)

f,s,c=max(list(cal_cons()),key=lambda x:x[2])
print(f,s)

Submission status: Runtime Error

Solution code:
import sys

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

water_pattern = []
for i in range(f+1):
    for j in range(f+1):
        x = a*i*100 + b*j*100
        if x <= f and not x in water_pattern:
            water_pattern.append(x)

sugar_pattern = []
for i in range(f+1):
    for j in range(f+1):
        y = c*i + d*j
        if y <= f and not y in sugar_pattern:
            sugar_pattern.append(y)

sugarwater_max = -1
sugar_max = -1
concentration = 0
for i in range(len(water_pattern)):
    for j in range(len(sugar_pattern)):
        # if i == 0 and j == 0:
        #     continue
        # else:
        #     sugarwater = water_pattern[i] + sugar_pattern[j]
        #     if (water_pattern[i]/100) * e >= sugar_pattern[j] and sugarwater <= f:
        #         if sugarwater_max == -1 and sugar_max == -1:
        #             sugarwater_max = sugarwater
        #             sugar_max = sugar_pattern[j]
        #             concentration = 100 * sugar_pattern[j] / sugarwater
        #         else:
        #             if concentration < 100 * sugar_pattern[j] / sugarwater:
        #                 sugarwater_max = sugarwater
        #                 sugar_max = sugar_pattern[j]
        #                 concentration = 100 * sugar_pattern[j] / sugarwater

print("{} {}".format(sugarwater_max, sugar_max))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
density = 0
for i in range(F//(100*A) +1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*A*i + 100*B*j
        if water == 0:
            continue
        for k in range((F-water)//C+1):
            for l in range((F-water-C*k)//D+1):
                sugar = C*k + D*l
                if density < sugar/(sugar + water) and sugar <= (E/100)*water:
                    density = sugar/(sugar + water)
                    ans = [sugar+water, sugar]
print(ans[0], ans[1])

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
density = 0
for i in range((F//(100*A)) +1):
    for j in range(((F-100*A*i)//(100*B))+1):
        water = 100*A*i + 100*B*j
        if water == 0:
            continue
        for k in range(((F-water)//C)+1):
            for l in range(((F-water-C*k)//D)+1):
                sugar = C*k + D*l
                if density < sugar/(sugar + water) and sugar <= (E/100)*water:
                    density = sugar/(sugar + water)
                    ans = [sugar+water, sugar]
print(ans[0], ans[1])

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
density = 0
for i in range(F//(100*A) +1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*A*i + 100*B*j
        if water == 0:
            continue
        for k in range((F-water)//C+1):
            for l in range((F-water-C*k)//D+1):
                sugar = C*k + D*l
                if density < sugar/(sugar + water) and sugar <= (E/100)*water:
                    density = sugar/(sugar + water)
                    ans = [sugar+water, sugar]
print(ans)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
q=set()
ans=0
p=set()
for i in range(0,f+1,100*a):
    for j in range(0,f+1-i,100*b):
        q.add(i+j)
for i in range(0,f+1,c):
    for j in range(0,f+1-i,d):
        p.add(i+j)
for pp in p:
    for qq in q:
        if 0<pp+qq and qq<=pp*e/100:
            if ans<qq/(pp+qq):
                ans=qq/(pp+qq)
                s=pp+qq
                ss=pp

print(s,ss)

Submission status: Runtime Error

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

max = 0
sw = 0
s = 0

for b in range(0,31):
  for a in range(0,b):
    for c in range(0,a+b):
      for d in range(0,a+b-d):
        if 100*(c+d)/(100*(a+b)+c+d) > max:
          max = 100*(c+d)/(100*(a+b)+c+d)
          sw =  100*(a+b)+c+d
          s = c+d
        
print(sw, s)

Submission status: Runtime Error

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B, C, D, E, F = map(int, input().split())
    rate = 0
    for i in range(30//A+1):
        for j in range(30//B+1):
            if i==0 and j==0:
                continue
            water = A*i + B*j
            if water*100 > F:
                continue
            limit = water * E
            for s in range(limit//C+1):
                sugar = limit - (limit-C*s)%D
                if water*100 + sugar > F:
                    continue
                if rate < sugar/(sugar+water*100):
                    rate = sugar/(sugar+water*100)
                    res_water = water * 100
                    res_sugar = sugar
    print(res_water+res_sugar, res_sugar)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B, C, D, E, F = map(int, input().split())
    rate = 0
    for i in range(30//A+1):
        for j in range(30//B+1):
            if i==0 and j==0:
                continue
            water = A*i + B*j
            if water*100 > F:
                continue
            limit = water * E
            for s in range(limit//C+1):
                sugar = limit-((limit-C*s)%D)
                if sugar==0:
                    continue
                if water*100 + sugar > F:
                    continue
                if rate < sugar/(sugar+water):
                    rate = sugar/(sugar+water)
                    res_water = water * 100
                    res_sugar = sugar
    print(res_water+res_sugar, res_sugar)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B, C, D, E, F = map(int, input().split())
    rate = 0
    for i in range(30//A+1):
        for j in range(30//B+1):
            if i==0 and j==0:
                continue
            water = A*i + B*j
            if water*100 > F:
                continue
            limit = water * E
            for s in range(limit//C+1):
                sugar = limit-((limit-C*s)%D)
                if water*100 + sugar > F:
                    continue
                if rate < sugar/(sugar+water):
                    rate = sugar/(sugar+water)
                    res_water = water * 100
                    res_sugar = sugar
    print(res_water+res_sugar, res_sugar)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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

water = list(water)
water.sort()

if not water:
    print(0, 0)
    sys.exit()
suger = set()
for i in range(water[-1]*e//(100*c)+1):
    for j in range(water[-1]*e//(100*d)+1):
        k = i*c+j*d
        if k <= f:
            suger.add(k)
        else:
            break

suger = list(suger)
suger.sort()


weight_water, weight_suger = 0, 0
ratio = 0
n = len(suger)
for w in water:
    if w == 0:
        continue
    bit_l, bit_r = 0, n
    while bit_r - bit_l > 1:
        key = (bit_r+bit_l)//2
        s = suger[key]
        if s+w <= f and s*100 <= e*w:
            bit_l = key
        else:
            bit_r = key
    if bit_l == n-1 and (suger[bit_l]/(suger[bit_l]+w) > e or suger[bit_l]+w > f):
        continue
    if bit_l == 0 and suger[1]/(suger[1]+w) <= e and suger[1]+w <= f:
        ws = suger[1]
    else:
        ws = suger[bit_l]
    if ratio*w < ws*100 <= e*w:
        ratio = ws*100/w
        weight_water, weight_suger = w+ws, ws
print(weight_water, weight_suger)

Submission status: Runtime Error

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

water = set()
for i in range(f//(a*100)+1):
    for j in range(f//(b*100)+1):
        k = 100*(i*a+j*b)
        if k == 0:
            continue
        if k <= f:
            water.add(k)
        else:
            break

water = list(water)
water.sort()

suger = set()
for i in range(water[-1]*e//(100*c)+1):
    for j in range(water[-1]*e//(100*d)+1):
        k = i*c+j*d
        if k <= f:
            suger.add(k)
        else:
            break

suger = list(suger)
suger.sort()


weight_water, weight_suger = 0, 0
ratio = 0
n = len(suger)
for w in water:
    if w == 0:
        continue
    bit_l, bit_r = 0, n
    while bit_r - bit_l > 1:
        key = (bit_r+bit_l)//2
        s = suger[key]
        if s+w <= f and s*100 <= e*w:
            bit_l = key
        else:
            bit_r = key
    if bit_l == n-1 and (suger[bit_l]/(suger[bit_l]+w) > e or suger[bit_l]+w > f):
        continue
    if bit_l == 0 and suger[1]/(suger[1]+w) <= e and suger[1]+w <= f:
        ws = suger[1]
    else:
        ws = suger[bit_l]
    if ratio*w < ws*100 <= e*w:
        ratio = ws*100/w
        weight_water, weight_suger = w+ws, ws
print(weight_water, weight_suger)

Submission status: Runtime Error

Solution code:
import sys

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

water = set()
for i in range(f//(a*100)+1):
    for j in range(f//(b*100)+1):
        k = 100*(i*a+j*b)
        if k == 0:
            continue
        if k <= f:
            water.add(k)
        else:
            break

water = list(water)
water.sort()

suger = set()
for i in range(water[-1]*e//(100*c)+1):
    for j in range(water[-1]*e//(100*d)+1):
        k = i*c+j*d
        if k <= f:
            suger.add(k)
        else:
            break

suger = list(set(suger))
suger.sort()


weight_water, weight_suger = 0, 0
ratio = 0
n = len(suger)
for w in water:
    bit_l, bit_r = 0, n
    while bit_r - bit_l > 1:
        key = (bit_r+bit_l)//2
        s = suger[key]
        if s+w <= f and s*100 <= e*w:
            bit_l = key
        else:
            bit_r = key
    if bit_l == n-1 and (suger[bit_l]/(suger[bit_l]+w) > e or suger[bit_l]+w > f):
        continue
    if bit_l == 0 and suger[1]/(suger[1]+w) <= e and suger[1]+w <= f:
        ws = suger[1]
    else:
        ws = suger[bit_l]
    if ratio*w < ws*100 <= e*w:
        ratio = ws*100/w
        weight_water, weight_suger = w+ws, ws
print(weight_water, weight_suger)

Submission status: Runtime Error

Solution code:
suger_water = A
suger = C
over = False
for a in range(0, 31):
    for b in range(0, 31):
        water = 100*A*a + 100*B*b
        c_ceil = int(water * conc_filter)
        for c in range(0, c_ceil):
            for d in range(0, c_ceil):
                suger = C*c + D*d
                suger_water = water + suger
                if suger_water > F:
                    break
                if (suger_water == 0): break
                conc = suger / suger_water
                if (conc > conc_filter): break
                if conc > max_conc:
                    ans_suger = suger
                    ans_suger_water = suger_water
print(ans_suger_water, ans_suger)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
n1, n2 = f//(100*a), f//(100*b)
m1, m2 = e*f//((100+e)*c), e*f//((100+e)*d)
lis1, lis2 = [], []
for i in range(n1+1):
    for j in range(n2+1):
        x = 100*a*i + 100*b*j
        if x != 0 and x <= f and lis1.count(x) == 0:
            lis1.append(x)
lis1.sort()
for i in range(m1+1):
    for j in range(m2+1):
        y = c*i + d*j
        if y <= e*f/(100+e) and lis2.count(y) == 0:
            lis2.append(y)
lis2.sort()
lis = []
for i in lis1:
    for j in lis2:
        if i + j <= f and j*100 <= i*e:
            lis.append([i, j])
p,q = 0,0
for i in lis:
    r = i[1]/i[0]
    if r > p:
        p = r
        q = i
print(q[0]+q[1], q[1])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
n1, n2 = f//(100*a), f//(100*b)
m1, m2 = e*f//((100+e)*c), e*f//((100+e)*d)
lis1, lis2 = [], []
for i in range(n1+1):
    for j in range(n2+1):
        x = 100*a*i + 100*b*j
        if x == 0:
            continue
        if x <= f and lis1.count(x) == 0:
            lis1.append(x)
lis1.sort()
for i in range(m1+1):
    for j in range(m2+1):
        y = c*i + d*j
        if y <= e*f/(100+e) and lis2.count(y) == 0:
            lis2.append(y)
lis2.sort()
lis = []
for i in lis1:
    for j in lis2:
        if i + j <= f and j*100 <= i*e:
            lis.append([i, j])
p,q = 0,0
for i in lis:
    r = i[1]/i[0]
    if r > p:
        p = r
        q = i
print(q[0]+q[1], q[1])

Submission status: Runtime Error

Solution code:
m_t = 0
m_s = 0
for a in range(F//100*A+1):
  for b in range((F-100*A*a)//(B)+1):
    for c in range((F-A*a*100-B*b*100)//C+1):
      d = 0
      while (100*A*a+100*B*b) > 0 and 100*A*a+100*B*b+C*c+D*d < F and (C*c+D*d)/(100*A*a+100*B*b) <= E/100:
        dens = (C*c+D*d)/(100*A*a+100*B*b)
        if (C*c+D*d)/(100*A*a+100*B*b) == E/100:
          print(100*A*a+100*B*b+C*c+D*d,C*c+D*d)
          exit()
        elif m_d < dens:
          m_d = dens
          m_t = 100*A*a+100*B*b+C*c+D*d
          m_s = C*c+D*d
        d += 1
print(m_t,m_s)

Submission status: Runtime Error

Solution code:
# 100(aA + bB) + cC + dD <= F
# cC + dD <= (aA + bB)E
# maximize 100(cD + dD) / (100(aA + bB) + cC + dD)

A, B, C, D, E, F = map(int, input().split())
concentration = 0
ans = None
for a in range(31):
    for b in range(31):
        water = 100*(a*A + b*B)
        if water > F:
            break
        for c in range(3001):
            for d in range(3001):
                sugar = c*C + d*D
                if water + sugar == 0:
                    continue
                if water + sugar > F:
                    break
                if sugar > water // 100 * E:
                    break
                conc = 100*sugar / (water + sugar)
                if concentration < conc:
                    concentration = conc
                    ans = (water + sugar, sugar)
print(ans[0], ans[1])

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxx=0
for i in range(F//(100*B)+1):
    for j in range((F-i*100*B)//(100*A)+1):
        for k in range(((i*B+j*A)*E)//D+1):
            for l in range (((i*B+j*A)*E-k*D)//C+1):
                if i==0 and j==0 and k==0 and l==0:
                    continue
                if (100*(i*B+j*A)+k*D+l*C)>F:
                    break
                elif (k*D+l*C)/(k*D+l*C+100*(i*B+j*A))>maxx:
                    maxx=(k*D+l*C)/(k*D+l*C+100*(i*B+j*A))
                    s=(k*D+l*C+100*(i*B+j*A))
                    t=k*D+l*C

print(s,t)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxx=0
for i in range(F//(100*B)+1):
    for j in range((F-i*100*B)//(100*A)+1):
        for k in range(((i*B+j*A)*E)//D+1):
            for l in range (((i*B+j*A)*E-k*D)//C+1):
                if i==0 and j==0 and k==0 and l==0:
                    continue
                if (100*(i*B+j*A)+k*D+l*C)>F:
                    break
                elif (k*D+l*C)/(k*D+l*C+100*(i*B+j*A))>maxx:
                    maxx=(k*D+l*C)/(k*D+l*C+100*(i*B+j*A))
                    s=(k*D+l*C+100*(i*B+j*A))
                    t=k*D+l*C

print(s,t)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
for i in range(F//(100*B)+1):
    for j in range((F-i*100*B)//(100*A)+1):
        for k in range(((i*B+j*A)*E)//D+1):
            for l in range (((i*B+j*A)*E-k*D)//C+1):
                if i==0 and j==0 and k==0 and l==0:
                    continue
                if (100*(i*B+j*A)+k*D+l*C)>F:
                    break
                elif (k*D+l*C)/(k*D+l*C+100*(i*B+j*A))>maxx:
                    s=(k*D+l*C+100*(i*B+j*A))
                    t=k*D+l*C

print(s,t)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxx=0
print(A,B,C,D,E,F)
print(F//(100*B))
print((F%100*B)//100*A)
for i in range(F//(100*B)+1):
    for j in range((F-i*100*B)//(100*A)+1):
        for k in range(((i*B+j*A)*E)//D+1):
            for l in range (((i*B+j*A)*E-k*D)//C+1):
                if i==0 and j==0 and k==0 and l==0:
                    continue
                if (100*(i*B+j*A)+k*D+l*C)>F:
                    break
                elif (k*D+l*C)/(k*D+l*C+100*(i*B+j*A))>maxx:
                    s=(k*D+l*C+100*(i*B+j*A))
                    t=k*D+l*C

print(s,t)

Submission status: Runtime Error

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b, c, d, e, f = LI()
ret = 0
for ai in range(f // (100 * a) + 1):
    for bi in range((f - ai * a) // (100 * b) + 1):
        limit = (ai * a + bi * b) * e
        for ci in range(limit // c + 1):
            di = (limit - ci * c) // d
            all_sum = ai * a * 100 + bi * b * 100 + ci * c + di * d
            sugar_sum = ci * c + di * d
            if all_sum and sugar_sum / all_sum > ret and all_sum < f:
                ret = sugar_sum / all_sum
                ans = (all_sum, sugar_sum)



print(*ans)

Submission status: Runtime Error

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

A *= 100
B *= 100
dp = [-1]*(F+1)
dp[A] = 0
dp[B] = 0
for i in range(A, F + 1):
    if A <= i:
        dp[i] = max(dp[i - A], dp[i])
    if B <= i:
        dp[i] = max(dp[i - B], dp[i])
    if C <= i and dp[i-C] >= 0:
        if dp[i-C] + C <= (i-C - dp[i-C]) * (E / 100):
            dp[i] = max(dp[i-C] + C, dp[i])

    if D <= i and dp[i-D] >= 0:
        if dp[i-D] + D <= ((i - D) - dp[i-D]) * (E / 100):
            dp[i] = max(dp[i-D] + D, dp[i])


x = 0
id = 0
for i in range(A, F+1):

    if x <= (dp[i] / (i)):
        x = dp[i] / (i)
        id = i

print(id, dp[id])

Submission status: Runtime Error

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

A, B, C, D, E, F = [int(x) for x in input().split()]

ans = [0, 0, -1]

for x in range((30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            if b + a > F or b > a * E:
                continue
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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

Submission status: Runtime Error

Solution code:
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a,b,c,d,e,f = inm()
s = [False]*3001
for i in range(3001):
    for j in range(1501):
        k = c*i+d*j
        if k<=f:
            s[k] = True
w = [False]*32
for i in range(31):
    for j in range(16):
        k = a*i+b*j
        if 100*k<=f:
            w[k] = True
mx = 0.0
for t in range(f-99):  # sugar gram
    if not s[t]:
        continue
    ww = t/e  # ww = ax+by must be this much
    for z in range(f//100 + 1, 0,-1):  # water/100
        if not w[z] or z*100+t>f:
            continue
        if z<ww:
            break
        r = t/(100*z+t)
        if r>mx:
            mx = r
            mxs = t
            mxsw = t+100*z
print("{} {}".format(mxsw,mxs))