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: Accepted

Solution code:
a, b, c, d, e, f = [int(x) for x in input().strip().split()]
a *= 100
b *= 100

water_cands = set()
t = 0
while t <= f:
    water_cands.add(t)
    u = t + b
    while u <= f:
        water_cands.add(u)
        u += b
    t += a

rat, wat, sug = 0.0, a, 0
for w in water_cands:
    if w == 0:
        continue
    suger_limit = min(f - w, w // 100 * e)
    suger_max = 0
    t = 0
    while t <= suger_limit:
        if suger_max < t:
            suger_max = t
        u = t + d
        while u <= suger_limit:
            if suger_max < u:
                suger_max = u
            u += d
        t += c
    if suger_max / (suger_max + w) > rat:
        rat = suger_max / (suger_max + w)
        wat = w
        sug = suger_max

print(wat + sug, sug)

Submission status: Accepted

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

    # A+B のアリエル値
    a_plus_b = set()
    for i in range(0, 31, A):
        for j in range(0, 31, B):
            if not (i == 0 and j == 0):
                if i + j <= 30:
                    a_plus_b.add(i + j)

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

    max_concent = -1
    ans_sum = 0
    ans_sugar = 0
    # print(c_plus_d)
    # print(a_plus_b)
    for cd in c_plus_d:
        for ab in a_plus_b:
            if cd <= E * ab and cd <= F - 100 * ab:
                if max_concent <= cd / ab:
                    max_concent = cd / ab
                    ans_sum = 100 * ab + cd
                    ans_sugar = cd

    print(str(ans_sum) + " " + str(ans_sugar))

Submission status: Accepted

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

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

tupleList = []

for i in range((f//a) + 1):
    for j in range((f - a*i)//b + 1):
        for k in range((f - a*i - b*j)//c + 1):
            for l in range((f - a*i - b*j - c*k)//d + 1):
                if (c*k + d*l)*(100 + e) <= (a*i + b*j + c*k + d*l)*e:
                    tupleList.append([i, j, k, l])
tupleList.remove([0, 0, 0, 0])

def concentration(i, j, k, l):
    return (c*k + d*l)/(a*i + b*j + c*k + d*l)

max_con = concentration(tupleList[0][0], tupleList[0][1], tupleList[0][2], tupleList[0][3])
max_tuple = tupleList[0]

for i in range(len(tupleList) - 1):
    if max_con < concentration(tupleList[i+1][0], tupleList[i+1][1], tupleList[i+1][2], tupleList[i+1][3]):
        max_con = concentration(tupleList[i + 1][0], tupleList[i + 1][1], tupleList[i + 1][2], tupleList[i + 1][3])
        max_tuple = tupleList[i + 1]

print(str(a*max_tuple[0] + b*max_tuple[1] + c*max_tuple[2] + d*max_tuple[3]) \
      + " " + str(c*max_tuple[2] + d*max_tuple[3]))

Submission status: Accepted

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

water = [1]
for i in range(30):
	water.append(0)

for i in range(31):
	if water[i] == 1:
		if (i + A) * 100 <= F:
			water[i + A] = 1

		if (i + B) * 100 <= F:
			water[i + B] = 1

K = []

for i in range(1, 31):
	if water[i] == 1:
		sugar = [1]
		X = min(i * E, F - 100 * i)
		for j in range(X):
			sugar.append(0)

		for j in range(X + 1):
			if sugar[j] == 1:
				if j + C <= X:
					sugar[j + C] = 1

				if j + D <= X:
					sugar[j + D] = 1
		sugar.reverse()
		s = sugar.index(1)
		WS = ((100 * (X - s) / (100 * i + X - s)), 100 * i + X - s, X - s)
		K.append(WS)

K = sorted(K)
print(K[-1][1], K[-1][2])

Submission status: Accepted

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

max_sato = e*f/100//1
max_mizu = f

def all_pattern(a,b,c):
    max_a = int(c//a)
    all_list = []
    for i in range(max_a+1):
        goukei = 0
        goukei += a*i
        j = 0
        while goukei <= c:
            if not goukei in all_list:
                all_list.append(goukei)
            goukei += b
    return all_list

mizu_pattern = all_pattern(a,b,max_mizu)
sato_pattern = all_pattern(c,d,max_sato)

satosui_situryo = 0
sato_situryo = 0
max_noudo = 0

for mizu in mizu_pattern:
    for sato in sato_pattern:
#         print(sato,mizu)
        if sato + mizu > 0:
            tmp_noudo = sato/(sato+mizu)*100
#             print(tmp_noudo)
            if max_noudo < tmp_noudo and tmp_noudo <= e/(100+e)*100 and mizu+sato <= f:
                max_noudo = tmp_noudo
                satosui_situryo = mizu + sato
                sato_situryo = sato
#                 print("a:",max_noudo,satosui_situryo,sato_situryo)

if satosui_situryo == 0:
    satosui_situryo += a

print(satosui_situryo,sato_situryo)

Submission status: Accepted

Solution code:
A,B,C,D,E,F=[int(x) for x in input().split()]
from itertools import product
def gauss(i):
    return F//i+1
waters=set()
sugers=set()
ans={"water":100*A,"suger":0}
for a,b in product(range(gauss(A)),range(gauss(B))):
    waters.add(100*(a*A+b*B))
for c,d in product(range(gauss(C)),range(gauss(D))):
    sugers.add(c*C+d*D)
for water in sorted(waters):
    if water==0:
        continue
    for suger in sorted(sugers):
        if water+suger>F:
            break
        if 100*suger>E*water:
            break
        if ans["suger"]*(water+suger)<suger*ans["water"]:
            ans={"water":water+suger,"suger":suger}
print(ans["water"],ans["suger"])

Submission status: Accepted

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

y = 0
yx = 100*A
ys= 0
W = {}
for a in range(F//100 + 1):
    for b in range(F//200 + 1):
        w = 100*A*a + 100*B*b
        if w <= F:
            W[w] = 0
        
for w in W.keys():
    for c in range(min(F-w, (E*w//100)) + 1):
        for d in range(min(F-w, (E*w//100))//2 + 1):
            s = C*c + D*d
            x = w + s
            try:
                if s+w <= F and s/x <= E/(100+E):
                    if s/x > y:
                        y = s/x
                        ys = s
                        yx = x
            except ZeroDivisionError:
                pass
                
print(yx, ys)

Submission status: Accepted

Solution code:

A,B,C,D,E,F = map(int, input().split(' '))
water = []
for i in range(int(F/(A*100))+1):
    for j in range(int(F/(B*100))+1):
        water.append(100*A*i+100*B*j)
water = list(set(water))
water = sorted(water)
water = [i for i in water if i <= F]
water = water[::-1]
water.remove(0)

suger = []
for i in range(int(F/C)+1):
    for j in range(int(F/D)+1):
        suger.append(C*i+D*j)
suger = list(set(suger))
suger = sorted(suger)
suger = [i for i in suger if i <= F]
suger = suger[::-1]

limit = E / (100.0+E)
maxAns = 0.0
for w in water:
    for s in suger:
        if s + w > F:
            continue
        tmp = s / float(s+w)
        if tmp <= limit and tmp >= maxAns:
            maxAns = tmp
            maxWS = w+s
            maxS = s
print(str(maxWS) + ' ' + str(maxS))

Submission status: Accepted

Solution code:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def get_composable_numbers(a, b, lim):
    result = set()
    result.add(0)
    if a < lim:
        result.add(a)
    if b < lim:
        result.add(b)

    for c in range(max(result), lim + 1):
        if (c - a) in result or (c - b) in result:
            result.add(c)

    return list(result)

def get_concentration(water, suger):
    return suger / (water + suger)

def max_below(array, limit):
    max_res = array[0]
    for elem in array:
        if elem > max_res and elem <= limit:
            max_res = elem
        elif elem >= limit:
            break

    return max_res

def main():
    a, b, C, D, E, F = get_ln_int_inputs()
    A = 100 * a
    B = 100 * b
    water_composables = sorted(list(map(lambda x: x * 100, get_composable_numbers(a, b, F // 100))))
    suger_composables = sorted(get_composable_numbers(C, D, (E * F) // 100))

    res_tuple = (A, 0)
    max_concentration = 0
    for i in range(1, len(water_composables)):
        water = water_composables[i]
        suger_max = max_below(suger_composables, min((water * E) // 100, F - water))
        mass = water + suger_max

        concentration = get_concentration(water, suger_max)
        if concentration > max_concentration:
            max_concentration = concentration
            res_tuple = (water + suger_max, suger_max)
    
    print(str(res_tuple[0]) + " " + str(res_tuple[1]))
    return

main()

Submission status: Accepted

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

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

alpha = E/(100.0+E) # 最大濃度（これを超えて終了することはできない）

#water = sugar = 0
sugar_limit = 0 # 水が100入るとEだけ増える（1入るとE/100増える），砂糖をn入れるとn減る

a = b = c = d = 0
a_max = F // (100*A)
b_max = F // (100*B)
#c_max = F // C
#d_max = F // D

water_pattern = []
for i in range(a_max+1):
    for j in range(b_max+1):
        water_pattern.append(100*A*i + 100*B*j)

# 溶かせるだけ溶かした場合の最大濃度を記憶
max_density = -1.0
ans_water = 0.0
ans_sugar = 0.0
for water_amount in water_pattern:
    if water_amount > F:
        continue
    sugar_limit = water_amount * (E/100)
    # 制限を超えない範囲でできるだけたくさんの砂糖を加える
    c_max = (F-water_amount) // C
    d_max = (F-water_amount) // D
    max_sugar_amount = -1.0
    sugar_pattern = []
    '''
    for i in range(c_max+1):
        for j in range(d_max+1):
            sugar_pattern.append(C*i + D*j)
    for sugar_amount in sugar_pattern:
        if sugar_amount > sugar_amount
    '''
    for i in range(c_max+1):
        for j in range(d_max+1):
            sugar_amount = C*i + D*j
            if sugar_amount > sugar_limit or (sugar_amount+water_amount) > F:
                continue
            max_sugar_amount = max(max_sugar_amount, sugar_amount)
    density = -1.0
    if water_amount+max_sugar_amount > 0:
        density = (100*max_sugar_amount) / (water_amount+max_sugar_amount)
    else:
        continue
    if max_density < density:
        max_density = density
        ans_water = water_amount
        ans_sugar = max_sugar_amount

print((ans_water+ans_sugar), ans_sugar)

Submission status: Accepted

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

counter = []

cnta = 1
cntb = 0
while (cnta * A) <= F:
  while (cnta * A + cntb * B) <= F:
    counter.append([cnta, cntb])
    cntb += 1
  cnta += 1
  cntb = 0

water = []
for c in counter:
  water.append(c[0] * A + c[1] * B)
water = list(set(water))

def sugar(water,C,D,E,F):
  sugar = []
  limit = water / 100 * E
  cntc = 0
  cntd = 0
  while cntc * C <= limit and cntc * C + water <= F:
    while cntc * C + cntd * D <= limit and cntc * C + cntd * D + water <= F:
      sugar.append(cntc * C + cntd * D)
      cntd += 1
    cntc += 1
    cntd = 0
  return max(sugar)

maxconc = [0,0,-1]
for w in water:
  s = sugar(w,C,D,E,F)
  conc = s/(w+s)
  if conc > maxconc[2]:
    maxconc = [w+s, s, conc]

print(" ".join(map(str, maxconc[0:2])))

Submission status: Accepted

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

ws = set()
i = j = 0
while True:
    j = 0
    if B*i > F//100: break
    while True:
        w = B*i + A*j
        if w > F//100: break
        ws.add(w)
        j += 1
    i += 1
ws = list(ws)
ws.sort()

ss = set()
i = j = 0
while True:
    j = 0
    if D*i > F: break
    while True:
        s = D*i + C*j
        if s > F: break
        ss.add(s)
        j += 1
    i += 1
ss = list(ss)
ss.sort()

limit = E / (100+E)
water = A*100
sugar = rate = 0
for w in ws:
    w = w*100
    if w == 0: continue
    if w > F: break
    for s in ss:
        if w+s > F: break
        r = s / (w+s)
        if r > limit: break
        if r > rate:
            rate = r
            water = w
            sugar = s
print(water+sugar, sugar)

Submission status: Accepted

Solution code:
import math
A,B,C,D,E,F = map(int, input().split())
result_noudo=None
result_satosui=None
result_sato=None

for a in range(math.floor(F/100*A)+1):
    for b in range(math.floor((F-100*A*a)/100*B)+1):
        for c in range(math.floor((F-100*A*a-100*B*b)/C)+1):
            for d in range(math.floor((F-100*a*A-100*b*B-C*c)/D)+1):
                sum_under=100*a*A+100*b*B+C*c+D*d
                if (a==0 and b==0) or (d==0 and c==0):
                    continue
                sum_top=C*c+D*d
                noudo=(100*sum_top)/sum_under
                if sum_under<=F and noudo<=(100*E)/(100+E) and (result_noudo==None or noudo>result_noudo):
                    result_noudo=noudo
                    result_satosui=sum_under
                    result_sato=sum_top
if result_noudo==None:
    result_satosui=100*A
    result_sato=0
print(str(result_satosui)+" "+str(result_sato))

Submission status: Accepted

Solution code:
import sys

# utils
def read_numbers():
    return [int(num) for num in sys.stdin.readline().split()]
def read_string():
    return sys.stdin.readline().rstrip('\r\n')
def list2str(*array):
    return ' '.join([str(i) for i in array])

def main(nums):
    A, B, C, D, E, F = nums
    def density(sugar, water):
        if sugar + water == 0:
            return 0.0
        return sugar / (sugar + water)
    cache = {}
    def recurse(sugar, water):
        if (sugar, water) in cache:
            return cache[(sugar, water)]
        if sugar + water > F:
            return (0.0, 0, 0)
        if density(sugar, water) > density(E, 100):
            return (0.0, 0, 0)
        result = max(
            (density(sugar, water), sugar, water),
            recurse(sugar, water+100*A),
            recurse(sugar, water+100*B),
            recurse(sugar+C, water),
            recurse(sugar+D, water),
        )
        cache[(sugar, water)] = result
        return result
    dens, sugar, water = recurse(0,0)
    return "%d %d" % (sugar+water, sugar)




def parse_stdin():
    # N = read_numbers()
    # data = []
    # for i in range(N):
    #    data.append(read_numbers())
    nums = read_numbers()
    return nums

def test_main():
    """run pytest stdin.py to test"""
    assert main([17, 19, 22, 26, 55, 2802]) == "2634 934"

if __name__ == '__main__':
    nums = parse_stdin()
    result = main(nums)
    print(result)

Submission status: Accepted

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

# a,bの組み合わせで作れる水の量を全て計算する
water = set([])
sugar = set([])
max_all = f / 100
a_count = int(max_all // a)

# a, bで作られる全ての水
for i in range(a_count + 1):
    # i*aが存在
    j = 0
    while(True):
        if i == 0 and j == 0:
            j += 1
        if i*a + j*b <= max_all:
            water.add(i*a + j*b)
        else:
            break
        j += 1

c_count = int(f // c)

for i in range(c_count + 1):
    j = 0
    while(True):
        if i*c + j*d <= f:
            sugar.add(i*c + j*d)
        else:
            break
        j += 1

all_water = 0
all_sugar = 0
percent = 0

for i in water:
    for j in sugar:
        if j / (i*100 + j) <= e / (100 + e) and 100*i + j <= f:
            if percent <= j / (i*100 + j):
                all_water = (i*100 + j)
                all_sugar = j
                percent = j / (i*100 + j)

print(all_water, all_sugar)

Submission status: Accepted

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

ok = []
for ai in range(31):
    for bi in range(31):
        for ci in range(101):
            for di in range(101):
                ab = ai*a100 + bi*b100
                cd = ci*c + di*d
                if ab + cd > f:
                    break
                else:
                    if (ab/100) * e >= cd:
                        ok.append([ab + cd, cd])
print(*sorted(ok, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

Submission status: Runtime Error

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

dp=[-1]*(f + 1)
dp[0]=0
for i in range(f+1):
  if dp[i] == -1:
    continue
  for j in [a, b]:
    water = i + 100*j
    if water > f:
      continue
    dp[water] = 0
    salt_max = water * e / 100
    dd = int(salt_max - dp[i])
    dp_s = [0] * (dd + 1)
    dp_s[0] = 1
    for pp in range(dd + 1):
      if dp_s[pp] == 0:
        continue
      for k in [c, d]:
        if pp+k > dd:
          continue
        dp_s[pp+k] = 1
    sm = 0
    for index,dp_i in enumerate(dp_s):
      if dp_i != 0:
        sm = index
    if water + sm + dp[i] <= f:
      dp[water] = max(dp[water], sm + dp[i])

for i in range(f+1):
  if dp[i] > 0:
    ans = i
print(dp[ans] + ans, dp[ans])

Submission status: Runtime Error

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

dp=[-1]*(f + 1)
dp[0]=0
for i in range(f+1):
  if dp[i] == -1:
    continue
  for j in [a, b]:
    water = i + 100*j
    if water > f:
      continue
    dp[water] = 0
    salt_max = water * e / 100
    dd = int(salt_max - dp[i] + 1)
    dp_s = [0] * dd
    dp_s[0]=1
    for pp in range(dd):
      if dp_s[pp] == 0:
        continue
      for k in [c, d]:
        if pp+k >= dd:
          continue
        dp_s[pp+k] = 1
    sm = 0
    for index,dp_i in enumerate(dp_s):
      if dp_i != 0:
        sm = index
    if water + sm + dp[i] <= f:
      dp[water] = max(dp[water], sm + dp[i])

for i in range(f+1):
  if dp[i] > 0:
    ans = i
print(dp[ans] + ans, dp[ans])

Submission status: Runtime Error

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b,c,d,e,f = i_map()
    W = set()
    for i in range(0,f+1,a**100):
        for j in range(0,f+1, b*100):
            W.add(i+j)

    S = set()
    for i in range(0,f+1, c):
        for j in range(0, f+1, d):
            S.add(i+j)

    rate = -1

    for w in W:
        for s in S:
            if 0 < w+s <= f and s <= w*e//100:
                if s/(w+s) > rate:
                    rate = s/(w+s)
                    ans = w+s,s
    print(ans[0], ans[1])






if __name__=="__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    a,b,c,d,e,f = map(int,input().split())
    ans = []
    for i in range(f//a//100+1):
        for j in range((f-100*a*i)//b//100+1):
            if a*i*100+b*j*100 < f:
                ans.append([i,j])
    ans = ans[1:]
    D = 0
    for an in ans:
        m = a*100*an[0] + b*100*an[1]
        slv = e*m//100
        M = 0
        for i in range(min(f-m,slv)//c+1):
            for j in range((min(f-m,slv)-c*i)//d+1):
                if i*c+d*j <= min(slv,f-m):
                    if M < i*c+d*j:
                        M = i*c+d*j
        den = M/(m+M)
        if den>D:
            D = den
            A = [m+M,M]
    print(' '.join([str(a) for a in A]))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())A, B, C, D, E, F = map(int, input().split())
perc = 0.0
ans = [0, 0]
op = [0, 0, 0, 0]
a = 0
while 100 * a <= F:
  b = 0
  while 100 * (a + b) <= F:
    c = 0
    while 100 * (a + b) + c <= F:
      if c > (a + b) * E:
        break
      d = 0
      while 100 * (a + b) + c + d <= F:
        if c + d > (a + b) * E:
          break
        if a == b == c == d == 0:
          break
        p = (c + d) * 1.0 / (100 * (a + b) + c + d)
        if p > perc:
          perc = p
          ans = [100 * (a + b) + c + d, c + d]
          op = [a, b, c, d]
        d += D
      c += C
    b += B
  a += A
print(str(ans[0]) + " " + str(ans[1]))

Submission status: Runtime Error

Solution code:
def main():
    A, B, C, D, E, F = map(int, input().split())
    ans = 0
    for a in range(F // (A * 100) + 1):
        for b in range((F - 100 * A * a) // (B * 100) + 1):
            for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
                for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                    x = a * A + b * B
                    y = c * C + d * D
                    if x == 0:
                        continue
                    if x * E >= y and ans < (100 * y)/(x*100+y):
                        ans = (100 * y)/(x*100+y)
                        sugar = y
                        sugar_water = 100 * x + y
    print(sugar_water,sugar)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:

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

dict = {}
for a in range(E//100*A):
  for b in range((E-100*A*a)//100*B):
    for c in range((E-100*A*a-100*B*b)//C):
      for d in range((E-100*A*a-100*B*b-C*c)//D):
        sato = C*c + D*d
        water = 100*(A*a + B*b)
        nodo = 100*sato/(sato+water)
        if nodo < F:
          dict[water] = nodo
print(dict)
#y = min(dict.values())

Submission status: Runtime Error

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

def reduce(x): #約分
  #print(x)
  d = math.gcd(x[0], x[1])
  return (x[0] // d, x[1] // d)

def is_valid(s, w): #砂糖s、水100w
  return s <= w * E and s + 100*w <= F

ratios = set()

Waters = [] 
for a in range(0, w_max+1, A):
  for b in range(0, w_max+1, B):
    if a == 0 and b == 0:
      continue
    Waters.append(a+b)
Waters.sort()

s_max = 0
for x in Waters:
  s_max = max(s_max, min(x*E,F-100*x))

Sugars = [] 
for c in range(0, s_max+1, C):
  for d in range(0, s_max+1, D):
    Sugars.append(c+d)
Sugars.sort()

i = 0
ascend = True
for w in Waters:
  if Sugars[i]*100 + w > F:
    ascend = False
  if ascend:
    while i < len(Sugars) and is_valid(Sugars[i], w):
      i += 1
    i -= 1
  else:
    while i >= 0 and not is_valid(Sugars[i], w):
      i -= 1
  ratios.add(reduce((Sugars[i], w)))

ans = max(ratios, key = lambda x: float(x[0]/x[1]))
print(ans[1]*100 + ans[0], ans[0])

Submission status: Runtime Error

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

def reduce(x): #約分
  #print(x)
  d = math.gcd(x[0], x[1])
  return (x[0] // d, x[1] // d)

def is_valid(s, w): #砂糖s、水100w
  return s <= w * E and s + 100*w <= F

ratios = set()

Waters = [] 
for a in range(0, w_max, A):
  for b in range(0, w_max, B):
    if a == 0 and b == 0:
      continue
    Waters.append(a+b)
Waters.sort()

s_max = 0
for x in Waters:
  s_max = max(s_max, min(x*E,F-100*x))

Sugars = [] 
for c in range(0, s_max, C):
  for d in range(0, s_max, D):
    Sugars.append(c+d)
Sugars.sort()

i = 0
ascend = True
for w in Waters:
  if Sugars[i]*100 + w > F:
    ascend = False
  if ascend:
    while i < len(Sugars) and is_valid(Sugars[i], w):
      i += 1
    i -= 1
  else:
    while i >= 0 and not is_valid(Sugars[i], w):
      i -= 1
  ratios.add(reduce((Sugars[i], w)))

ans = max(ratios, key = lambda x: float(x[0]/x[1]))
print(ans[1]*100 + ans[0], ans[0])

Submission status: Runtime Error

Solution code:
from math import gcd

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

N = 0
f = F//100; a = f//A; b = f//B
cn = D // gcd(C, D)

for j in range(b+1): #Bをj杯入れる
    for i in range(a+1): #Aをi杯入れる
        if i==0 and j==0:
            continue
        elif A*i + B*j > f:
            continue
        w = (A*i + B*j) * 100 #水の量
        e = (A*i + B*j) * E #この場合において溶ける砂糖の最大値
        S = min(e, F-w) #ビーカーも考慮した砂糖を入れられる限界
        s = 0
        for ci in range(min(S//C, cn)+1):
            s = max(s, S - (S - C*ci) % D)
        if s/(w+s) > N:
            N = s/(w+s)
            max_SW = s + w
            max_S = s

print(max_SW, max_S)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int, input().split())
amax=f//(a*100)
bmax=f//(b*100)
c_list=[]
sw_list=[]
s_list=[]

for i in range(amax+1):
   for j in range(bmax+1):
       water=100*a*i+100*b*j
       if water>0:
           smax=f-water
           for k in range(smax+1):
               for l in range(smax+1):
                   sugar=c*k+d*l
                   if water*e/100>=sugar and sugar>0:
                       concentration=100*sugar/(water+sugar)
                       c_list.append(concentration)
                       sw_list.append(sugar+water)
                       s_list.append(sugar)
num=c_list.index(max(c_list))
print(sw_list[num],s_list[num])

Submission status: Runtime Error

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

CCT = {}
for a in range(F//(100*A)+1):
    for b in range(F//(100*B)+1):
        water = (a*A+b*B)*100
        max_suger = water*E//100
        for c in range(max_suger//C+1):
            for d in range(max_suger//D+1):
                suger = c*C+d*D
                if water + suger > F:
                    continue
                if max_suger < suger:
                    continue
                if water+suger == 0:
                    continue
                CCT[water,suger] = 100*suger/(water+suger)

max_cct = 0
for (water,suger),cct in CCT.items():
    if cct > max_cct:
        max_cct = cct
        ans = [water+suger, suger]
print(*ans)

Submission status: Runtime Error

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c, d, e, f = LI()

x = f // (100*a)
y = f // (100*b)

max_ = 0
max__ = 1
for i in range(x + 1):
    for j in range(y + 1):
        if i == 0 and j == 0:
            continue
        E = min((a*i + b*j)*e, f-(100*a*i + 100*b*j))
        E -= min(E % c, E % d)
        if max_ * (a*i + b*j) < E * max__:
            max_ = E
            max__ = a*i + b*j
            ans1 = (a*i + b*j) * 100 + E
            ans2 = E
print(ans1, ans2)

Submission status: Runtime Error

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c, d, e, f = LI()

x = f // 100*a
y = f // 100*b

max_ = 0
for i in range(x + 1):
    for j in range(y + 1):
        if i == 0 and j == 0:
            continue
        E = min((i + j)*e, f-(100*i + 100*j))
        E -= min(E % c, E % d)
        if max_ < E / (i+j):
            max_ = E / (i+j)
            ans1 = (i + j) * 100 + E
            ans2 = E
print(ans1, ans2)

Submission status: Runtime Error

Solution code:
from math import gcd
A,B,C,D,E,F = (int(T) for T in input().split())
SugerMax = 0
for TC in range(0,D//gcd(C,D)):
    RestC = F-C*TC
    for TD in range(0,(RestC//D)+1):
        RestD = RestC-D*TD
        Suger = C*TC+D*TD
        if RestD>=0:
            NeedMin = (100*Suger)/E
            for TA in range(0,B//gcd(A,B)):
                for TB in range(0,(F//100)+1):
                    Water = A*TA*100+B*TB*100
                    if Water<=RestD:
                        if NeedMin<=Water and SugerMax<Suger:
                            SugerMax = Suger
                            WaterMax = Water
                    else:
                        break
        else:
            break
print('{} {}'.format(WaterMax+SugerMax,SugerMax))

Submission status: Runtime Error

Solution code:
dens = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range((F-(100*A*i))//(100*B)+1):
        for k in range((F-(100*A*i)-(100*B*j))//C+1):
            for l in range((F-(100*A*i)-(100*B*j)-(100*C*k))//D+1):
                water = 100*A*i+100*B*j
                sugar = C*k+D*l
                if i==j==0:
                    break
                if water+sugar <= F and sugar <= E*(A*i+B*j):
                    if dens<sugar/(sugar+water):
                        dens = sugar/(sugar+water)
                        ans_water = water
                        ans_sugar = sugar
print(ans_water+ans_sugar, ans_sugar)