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:
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]*31
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(3001):  # 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))

Submission status: Runtime Error

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

density = 0
max_density = 0
ans = []
for a in range(31):
    if a*A*100> F:
        break
    for b in range(31):
        if a==0 and b==0:
            break
        if a*A*100+b*B*100>F:
            break
        for c in range(101):
            for d in range(101):
                if a*A*100+b*B*100*c*C+d*D>F:
                    break
#                 print(a*A*100 + b*B*100 + c*C + d*D)
                if ( a*A*100 + b*B*100 + c*C + d*D <= F ) and ( 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D) <= 100*E/(100+E) ):
                    density = 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D)
#                     print(density)
#                     print("{} {}".format(a*A*100+b*B*100, c*C+d*D))
                    if max_density < density:
#                         print(max_density)
                        max_density = density
                        ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))
print(ans[-1])

Submission status: Runtime Error

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

w = set()
for i in range(F // (100 * A) + 1):
    t = F - 100 * a
    for j in range(t // (100 * B) + 1):
        a = (A * i + B * j) * 100
        w.add(a)
w.remove(0)

s = set()
t = E * F // 100
for i in range(t // C + 1):
    for j in range(t // D + 1):
        b = C * i + D * j
        if b < t:
            s.add(b)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in sorted(s):
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)

Submission status: Runtime Error

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

w = set()
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = (A * i + B * j) * 100
        if a < F:
            w.append(a)
w.remove(0)

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for i in range((F - a) // C + 1):
        for j in range((F - a) // D + 1):
            b = C * i + D * j
            if a + b > F:
                continue
            if b > E * a // 100:
                continue
            concentration = 100 * b / (a + b)
            if concentration > best_concentration:
                best_concentration = concentration
                best_a = a
                best_b = b
print(best_a + best_b, best_b)

Submission status: Runtime Error

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

water = set()
sugar = set()
res = {}
noudo = []

counter = max([int(F / A), int(F / B)])
A_counter = int(F / (A * 100))
B_counter = int(F / (B * 100))
for i in range(A_counter + 1):
    for j in range(B_counter + 1):
        tmp = A * i * 100 + B * 100 * j
        if tmp <= F:
            water.add(tmp)

C_counter = int(F / C)
D_counter = int(F / D)
for i in range(C_counter + 1):
    for j in range(D_counter + 1):
        tmp = i * C + D * j
        if tmp < F:
            sugar.add(tmp)

water.remove(0)
sugar.remove(0)

for w in water:
    for s in sugar:
        if w + s <= F and s <= E * (w / 100):
            n = s / (w + s)
            noudo.append(n)
            res[n] = {"satoumizu": w + s, "sugar": s}
ans = res[max(noudo)]
# print(" ".join([str(ans["satoumizu"]), str(ans["sugar"])]))
print(str(ans["satoumizu"]) + " " + str(ans["sugar"]))

Submission status: Runtime Error

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

water = set()
sugar = set()
res = {}
noudo = []

counter = max([int(F / A), int(F / B)])
A_counter = int(F / (A * 100))
B_counter = int(F / (B * 100))
for i in range(A_counter + 1):
    for j in range(B_counter + 1):
        tmp = A * i * 100 + B * 100 * j
        if tmp <= F:
            water.add(tmp)

C_counter = int(F / C)
D_counter = int(F / D)
for i in range(C_counter + 1):
    for j in range(D_counter + 1):
        tmp = i * C + D * j
        if tmp < F:
            sugar.add(tmp)

water.remove(0)
sugar.remove(0)

for w in water:
    for s in sugar:
        if w + s <= F and s <= E * (w / 100):
            n = s / (w + s)
            noudo.append(n)
            res[n] = {"satoumizu": w + s, "sugar": s}
ans = res[max(noudo)]
# print(" ".join([str(ans["satoumizu"]), str(ans["sugar"])]))
print(str(ans["satoumizu"]) + " " + str(ans["sugar"]))

Submission status: Runtime Error

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

water = set()
sugar = set()
res = {}
noudo = []

counter = max([int(F / A), int(F / B)])
A_counter = int(F / (A * 100))
B_counter = int(F / (B * 100))
for i in range(A_counter + 1):
    for j in range(B_counter + 1):
        tmp = A * i * 100 + B * 100 * j
        if tmp <= F:
            water.add(tmp)

C_counter = int(F / C)
D_counter = int(F / D)
for i in range(C_counter + 1):
    for j in range(D_counter + 1):
        tmp = i * C + D * j
        if tmp < F:
            sugar.add(tmp)

water.remove(0)
sugar.remove(0)

for w in water:
    for s in sugar:
        if w + s <= F and s <= E * (w / 100):
            n = s / (w + s)
            noudo.append(n)
            res[n] = {"satoumizu": w + s, "sugar": s}
ans = res[max(noudo)]
print(" ".join([str(ans["satoumizu"]), str(ans["sugar"])]))

Submission status: Runtime Error

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

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range(int((E*w / 100) / C) + 1) for d in range(int((E*w / 100) / D) + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(A[0] if W[I] == 0 else W[I] + S[I], S[I])

Submission status: Runtime Error

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

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range((E*w / 100) / C + 1) for d in range((E*w / 100) / D + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(W[I] + S[I], S[I])

Submission status: Runtime Error

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

per = -1
#水の量を100g単位ずつ全探索
for w in range(1,f+1):
    #そのような水の取り方があるか確認
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    sugar = w*E
    #砂糖として考えられる量を大きい順に0gまでに全探索
    for s in range(sugar,-1,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break
    if s+water <= F and s/(s+water) >= per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

Submission status: Runtime Error

Solution code:
#F<=3000で100刻みなので、多分全探索すればよさそう
A,B,C,D,E,F = map(int,input().split())
f = F//100

per = -1
#水の量を100g単位ずつ全探索
for w in range(1,f+1):
    #そのような水の取り方があるか確認
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    sugar = w*E
    #砂糖として考えられる量を大きい順に0gまでに全探索
    for s in range(sugar,-1,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break
    if s+water <= F and s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

Submission status: Runtime Error

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

per = 0

for w in range(1,f+1):
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    sugar = w*E

    for s in range(sugar,-1,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break
    if s+water <= F and s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

Submission status: Runtime Error

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

per = 0
#水の量を100g単位ずつ全探索
for w in range(1,f+1):
    #そのような水の取り方があるか確認
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    sugar = w*E
    #砂糖として考えられる量を大きい順に0gまでに全探索
    for s in range(sugar,-1,-1):
        #そのような砂糖の取り方があるか確認
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break
    if s+water <= F and s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

Submission status: Runtime Error

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

per = 0
#水の量を100g単位ずつ全探索
for w in range(1,f+1):
    #そのような水の取り方があるか確認
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    sugar = w*E
    #砂糖として考えられる量を大きい順に0gまでに全探索
    for s in range(sugar,-1,-1):
        そのような砂糖の取り方があるか確認
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break
    if s+water <= F and s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = tuple(map(int, input().split()))
max_con = 0
res = None
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                x = 100 * A * i + 100 * B * j
                y = C * k + D * l
                if x + y != 0 and x + y <= F and y <= (x // 100) * E \
                        and max_con < y / (x + y):
                    max_con = y / (x + y)
                    res = (x + y, y)
                    # print(x + y, y)
print(*res)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
a, b = a*100, b*100
limit_a = f//a +1
limit_b = f//b +1
limit_c = f//c +1
limit_d = f//d +1

rslt = 0
for i in range(limit_a):
    for j in range(limit_b):

        water = a*i + b*j
        if water == 0 or water > f:break

        for k in range(limit_c):
            for l in range(limit_d):

                solt = c*k + d*l
                all = water + solt
                if all > f :break
                elif solt/water*100 < e:
                    if(rslt < solt/water):
                        r_solt = solt
                        r_all = all
                        rslt = solt/water                        
                elif solt/water*100 == e:
                    print("{} {}".format(all, solt))
                    exit()
                else :break

print("{} {}".format(r_all, r_solt))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
Swater, sugar, percent = 0, 0, 0
for k in range(F//(100*A) + 1):
  for l in range(F//(100*B) + 1):
    if k == 0 and l == 0:
      continue
    M = k*A + l*B
    if 100 * M > F:
      continue
    for x in range(M*E//C + 1):
      for y in range(M*E//D + 1):
        S = C*x + D*y
        if 100*M+S > F:
          continue
        if S > M*E:
          continue
        t = 100*S / (100*M+S)
        if t > percent:
          percent = t
          Swater = 100*M+S
          suger = S
print(Swater, suger)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f=map(int, input().split())
def g(x, y):
  if y==0:
    return 0
  else:
    return x/y
  
maxnodo=g(e, 100+e)
a*=100
b*=100

candnodo=0

q_max=f//b
for q in range(q_max, -1, -1):
  p_max=(f-b*q)//a
  for p in range(p_max, -1, -1):
    s_max=(f-(a*p+b*q))//d
    while s_max>0 and g(d*s_max, a*p+b*q+d*s_max)>maxnodo:
      s_max-=1
      
    for s in range(s_max, -1, -1):
      r=(f-(a*p+b*q+d*s))//c
      while r>0 and g(c*r+d*s, a*p+b*q+c*r+d*s)>maxnodo:
        r-=1
        
      if g(c*r+d*s, a*p+b*q+c*r+d*s)>candnodo:
        candnodo=g(c*r+d*s, a*p+b*q+c*r+d*s)
        out=[a*p+b*q+c*r+d*s, c*r+d*s]
        temp=[p, q, r, s]
print(*out)

Submission status: Runtime Error

Solution code:

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

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {"0":[0,0]}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]


a,b = map(int,result[str(max(noud))])

print(a,b)

Submission status: Runtime Error

Solution code:

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

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {"0",[0,0]}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]


a,b = map(int,result[str(max(noud))])

print(a,b)

Submission status: Runtime Error

Solution code:

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

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]

a = 0
b = 0
a,b = map(int,result[str(max(noud))])

print(a,b)

Submission status: Runtime Error

Solution code:

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

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]


a,b = map(int,result[str(max(noud))])

print(a,b)

Submission status: Runtime Error

Solution code:

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

water = []
for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        n = (i*A + j*B)*100
        if n <= F:
            water.append(n)
water = sorted(list(set(water)))

result = {}
noud = []
for i in water:
    suger_limit = E*(i//100)
    for j in range(suger_limit//C + 1):
        for k in range(suger_limit//D + 1):
            n = j*C + k*D
            if n <= suger_limit and i + n <= F and n != 0:
                noudo = 100*n/(i+n)
                noud.append(noudo)
                
                result[str(noudo)] = [i+n,n]


print(result[str(max(noud))])

Submission status: Runtime Error

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

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

show_flg=False
#show_flg=True

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

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

show(A,B,C,D,E,F)
show(tmp)
print(*ans)

Submission status: Runtime Error

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

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

show_flg=False
show_flg=True

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

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

show(A,B,C,D,E,F)
show(tmp)
print(*ans)

Submission status: Runtime Error

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

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

show_flg=False
#show_flg=True

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

m=0

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

print(*ans)

Submission status: Runtime Error

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

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

show_flg=False
#show_flg=True

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

m=0

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

show(A,B,C,D,E,F)
show(tmp)
print(*ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
a,b,c,d,e,f = map(int,input().split())
water_nodo = 100 /(100 + e)
water_max = f*water_nodo
a_max = math.ceil(water_max / (100*a))
b_max = math.ceil(water_max / (100*b))
water_gaps = []
for i in range(a_max):
  for j in range(b_max):
    water_gap = water_max - 100*a*i - 100*b*j
    if water_gap >= 0:
      water_gaps.append(water_gap)
sorted_water = sorted(water_gaps)
max_water = water_max - sorted_water[0]
sugar_max = max_water*e/100
c_max = math.ceil(sugar_max / c)
d_max = math.ceil(sugar_max / d)
sugar_gaps = []
for k in range(c_max):
  for l in range(d_max):
    sugar_gap = sugar_max - c*k - d*l
    if sugar_gap >= 0:
      sugar_gaps.append(sugar_gap)
sorted_sugar = sorted(sugar_gaps)
max_sugar = sugar_max - sorted_sugar[0]
print(str(int(max_water + max_sugar)) + " " + str(int(max_sugar)))

Submission status: Runtime Error

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

count = 0
for ai in range(int(f/(100*a))):
  for bi in range(int(f/(100*b))):
    waters.append((ai+1)*100 + bi*100)

waters = list(set(waters))

m = int((f / 100) * e)

sugars = []
for ci in range(int(m/c)):
  for di in range(int(m/d) + 1):
    if (ci*c)+(di*d) < m:
      sugars.append((ci * c) + (di * d))
sugars = list(set(sugars))

answer = 0
r = 0
for w in waters:
  for s in sugars:
    noudo = (100 * s) / (w + s)
    if (w + s) < f:
      if r < w + s:
        r = w + s
        answer = ((w + s), s)

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b, c, d, e, f = LI()
    lis = []
    for i in range(f //c + 1):
        for k in range(f // d + 1):
            lis.append(c * i + d * k)
    lis = list(set(lis))
    lis.sort()
    ans = [100 * a, 0]
    for i in range(f // 100 + 1):
        for k in range(f // 100 + 1):
            if i == k == 0:
                continue
            water = a * i + b * k
           	if water * 100 > f:
                continue
            if water * e <= f - water * 100:
                aa = bisect_right(lis, water * e) - 1
                if aa == -1:
                    continue
                aa = lis[aa]
                if ans[1] / ans[0] < aa / (water * 100 + aa):
                    ans = [water * 100 + aa, aa]
    print(*ans)

    return


#main
if __name__ == '__main__':
    solve()