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: Time Limit Exceeded

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: Time Limit Exceeded

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:
            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:
            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: Time Limit Exceeded

Solution code:
A,B,C,D,E,F=map(int,input().split())
mizu=[]
sio=[]
small=min(A,B)
shou=min(C,D)
for a in range(F//small):
    for b in range(F//small):
        z=100*A*a+100*B*b
        mizu.append(z)
for c in range(F//shou):
    for d in range(F//shou):
        y=C*c+D*d
        sio.append(y)
shokuennsui=[]
for e in mizu:
    for f in sio:
        list=[]
        w=e+f
        if w==0:
            pass
        elif w<=F and f/w<=E/(100+E):
            list.append(e)
            list.append(f)
            shokuennsui.append(list)
noudos=[]
for g in shokuennsui:
    noudo=g[1]/sum(g)
    noudos.append(noudo)
basho=noudos.index(max(noudos))
print(str(sum(shokuennsui[basho]))+' '+str(shokuennsui[basho][1]))

Submission status: Time Limit Exceeded

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


rate = 0
water = 0
suger = 0
for i in range(30 + 1):
    for j in range(30 + 1):
        for k in range(100 + 1):
            for l in range(100 + 1):
                w = 100 * a * i + 100 * b * j
                s = c * k + d * l
                if w + s <= 0:
                    break
                temp = w + s
                r = (s * 100) / temp
                if temp <= f and (a * i + b * j) * e >= s:
                    if rate <= r:
                        water = w
                        suger = s 
                        rate = r
print(water + suger, suger)

Submission status: Time Limit Exceeded

Solution code:
'''
数が少ないため、全探索を実施する
'''

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

ans_w = 0
ans_s = 0
ans_density = 0
max_density = (E / (100 + E)) * 100
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                work_w = 100 * A * i + 100 * B * j
                work_s = C * k + D * l

                # 水がなければNG
                if (work_s + work_w) == 0:
                    continue
                else:
                    work_density = 100 * work_s / (work_s + work_w)

                # 合計の重さがF以下で、100gあたりの砂糖がE以下でなければNG
                if (work_w + work_s > F) | (work_density > max_density):
                    continue

                # 濃度が現状の最大値よりも大きい場合、最大値を更新する
                if (work_density > ans_density):
                    ans_w = work_w
                    ans_s = work_s
                    ans_density = work_density

print(ans_w + ans_s, ans_s)

Submission status: Time Limit Exceeded

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

for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                water = (i * A + j * B) * 100
                sugar = k * C + l * D
                if water + sugar > F:
                    continue
                if sugar * 100 > water * E:
                    continue
                if sugar + water == 0:
                    density = 0
                else:
                    density = sugar / (sugar + water)
                if maxDensity < density:
                    ans_water = water
                    ans_sugar = sugar
                    maxDensity = density


print(ans_water + ans_sugar, ans_sugar)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="number"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True

 

 
#main
A,B,C,D,E,F=map(int,input().split())
A*=100
B*=100
mizu=[]
satou=[]

for a in range(0,F+1,A):
    for b in range(0,F+1,B):
        mizu.append(a+b)
for a in range(0,F+1,C):
    for b in range(0,F+1,D):
        satou.append(a+b)

mizu.sort()
satou.sort()

ans=None

for a in satou:
    for b in mizu:
        s=a+b
        if(s==0):continue
        if(s>F):continue
        if(a*100>E*b):continue
        if(ans==None):ans=[a,s]
        if(a*ans[1]>ans[0]*s):
            ans=[a,s]

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

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d,e,f = map(int,input().split())
A =a* 100
B =b* 100
l = []
for i in range(f//A+1):
    for j in range(f//B+1):
        if i*A+j*B <=f:
            W = i*A+j*B
            s = (W//100)*e
            # print(s)
            r = f - W
            for I in range(s//c+1):
                for J in range(s//d+1):
                    if I*c + J*d<=s and I*c + J*d+W <= f and W>0:
                        S =I*c + J*d
                        l.append([100*S/(W+S),W+S,S])
l.sort()

l = l[::-1]
# print(l[:10])
print(l[0][1],l[0][2])

Submission status: Time Limit Exceeded

Solution code:

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

density = 0
ans = (0, 0)

for a in range(31):
  for b in range(31):
    for c in range(100):
      for d in range(100):
        water = 100*a*A + 100*b*B
        suger = c*C + d*D
         
        if water + suger > F or water == 0:
          continue

        if suger > 0 and (suger / water * 100)  > E:
          continue
        
        tmp = (100 * suger)  / (water + suger)

        if tmp >= density:
          density = tmp
          ans = (water+suger, suger)

print(*ans)

Submission status: Time Limit Exceeded

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c,d,e,f=LI()

  ans_n=-inf
  ans_pair=[0,0]
  xf=100*e/(100+e)
  for i in range(31):
    for j in range(31):
      for k in range(101):
        for l in range(101):
          xa=100*a*i+100*b*j
          xb=c*k+d*l

          # print(xa,xb)
          if xa+xb>f:
            continue

          if xa+xb==0:
            continue

          xc=100*xb/(xa+xb)
          if xc>xf:
            continue

          if ans_n<xc:
            ans_n=xc
            ans_pair=[xa+xb,xb]

  return str(ans_pair[0])+' '+str(ans_pair[1])

# main()
print(main())

Submission status: Time Limit Exceeded

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

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

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

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

waters = list(waters)
waters.sort()

# 砂糖もFまでなのでとりうる量作れるやん
sugars = set()
sugars.add(C)
sugars.add(D)
q = deque([C,D])
while q:
    s = q.popleft()
    if s > F: continue
    for n in [C,D]:
        if s + n <= F:
            sugars.add(s+n)
            q.append(s+n)
sugars = list(sugars)
sugars.sort()

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

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

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

print(total, sugar)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# ABC074 C - Sugar Water
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a,b,c,d,e,f = nm()
L =[]
for aa in range(0,31):
    for bb in range(0,31):
        for cc in range(0,1001):
            for dd in range(0,1001):
                if 100*a<=100*a*aa+100*b*bb+c*cc+d*dd<=f:
                    L.append((aa,bb,cc,dd))

max_w = 0.0
idx = 10*7
for i,l in enumerate(L):
    water = 100*a*l[0]+100*b*l[1]+c*l[2]+d*l[3]
    sugar = c*l[2]+d*l[3]
    if (100+e)*100*sugar<=(100*e)*water:
        if l[0]>0 or l[1]>0:
            t = (sugar/water)*100
            if t>=max_w:
                max_w=t
                idx = i

for i,l in enumerate(L):
    if i==idx:
        water = 100*a*l[0]+100*b*l[1]+c*l[2]+d*l[3]
        sugar = c*l[2]+d*l[3]
        print(water,sugar)
        exit()

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d, e, f = [int(x) for x in input().split()]
threshold = e / (100 + e) * 100
max_concent = 0
max_total = 0
max_suger = 0
max_try = int(f / 10 * a)
for i in range(max_try):
    for j in range(max_try):
        for k in range(max_try):
            for l in range(max_try):                
                water = a * i * 100 + b * j * 100
                suger = c * k + d * l   
                if water == 0:
                    break
                concentration = suger / (water + suger) * 100
                if (water + suger > f or concentration > threshold) :
                    break
                else:
                    if concentration > max_concent:
                        max_concent = concentration
                        max_total = water + suger
                        max_suger = suger
print("{} {}".format(max_total, max_suger))

Submission status: Time Limit Exceeded

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

dic_w={}
i=0
while True:
    if (a*i*100)>f:
        break
    j=0
    while True:
        w=(a*i+b*j)*100
        if w==0:
            continue
        if w>f:
            break
        else:
            dic_w[w]=dic_w.get(w,0)+1
        j+=1
    i+=1
list_w=list(dic_w.keys())
list_w.sort()

dic_s={}
max_s=int(e*f/(100+e))
i=0
while True:
    if c*i>max_s:
        break
    j=0
    while True:
        s=c*i+d*j
        if s>max_s:
            break
        else:
            dic_s[s]=dic_s.get(s,0)+1
        j+=1
    i+=1
list_s=list(dic_s.keys())
list_s.sort()

max_per=0
flag=False
ans_w=0
ans_s=0
for w in list_w:
    if flag==True:
        break
    for s in list_s:
        if s/(w/100)==e and s+w<=f:
            ans_w=w
            ans_s=s
            flag=True
            break
        if s/(w/100)>e:
            break
        if s/(w/100)>max_per and s+w<=f:
            ans_w=w
            ans_s=s
print('{} {}'.format(ans_w+ans_s,ans_s))

Submission status: Time Limit Exceeded

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

water = []
sugar =[]
ans = [-1] * 3
for i in range(F+1):
    for j in range(F+1):
        y = i * C + j * D
        if y <= F:
            sugar.append(y)

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

for i in range(len(water)):
    for j in range(len(sugar)):
        a = water[i]
        b = sugar[j]
        if a + b <= F and a / 100 * E >= b:
            if ans[0] * (a + b) < 100 * b:
                ans[0] = 100 * b / (a + b)
                ans[1] = a + b
                ans[2] = b
print("{} {}".format(ans[1], ans[2]))

Submission status: Time Limit Exceeded

Solution code:
def solve():
  A, B, C, D, E, F = map(int, input().split())
  memo = {}
  for a in range(31):
    for b in range(31):
      for c in range(101):
        for d in range(101):
          w = (100*A)*a + (100*B)*b
          s = C*c + D*d
          if w ==0:
            break
          if w+s > F:
            break
          else:
            if w/100 * E >= s:
              density = 100*s/(w+s)
              memo[a,b,c,d] = density
              max_v = max(memo.values())
  for k, v in memo.items():
    if v == max_v:
      print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
      break
if __name__ == '__main__':
  solve()

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d,e,f=map(int,input().split())
checklist=[]
for num1 in range(f+1):
    for num2 in range(f+1):
        #(0からfまでの値を num1とnum2に代入して調べる)
        if (100*a)*(num1)+(100*b)*(num2)<=f and [num1,num2]!=[0,0] and (100*num1)*a+(100*num2)*b not in checklist:
            checklist.append((100*num1)*a+(100*num2)*b)
sugarlist=[]
for i in range(f+1):
    for j in range(f+1):
        ch=c*(i)+d*(j)
        if ch<f and ch not in sugarlist and [i,j]!=[0,0]:
            sugarlist.append(ch)           
sugarlist .append(0)
maxsugar=0
ratio=-1
good=0           
for x in sugarlist:
    for y in checklist:
        allsum=x+y
        if allsum<=f and 100*x<=e*y:
            if x/y>=ratio:
                ratio=x/y
                maxsugar=x
                good=x+y      
            else:
            	continue       
        else:
            continue  
print(good,maxsugar)

Submission status: Time Limit Exceeded

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, D, E, F = map(int, input().split())

        sousa1 = 0
        sousa2 = 0
        ans = (0, 0, 0)
        while True:
            if sousa1 * 100 * A > F:
                break
            while True:
                water = sousa1 * 100 * A + sousa2 * 100 * B
                if water == 0:
                    continue
                if water > F:
                    sousa2 = 0
                    break
                sugar_limit = water // 100 * E
                sousa3 = 0
                sousa4 = 0
                max_sugar = 0
                while True:
                    if sousa3 * C > sugar_limit:
                        break
                    while True:
                        sugar = sousa3 * C + sousa4 * D
                        if water + sugar > F or sugar > sugar_limit:
                            sousa4 = 0
                            break
                        else:
                            max_sugar = max(max_sugar, sugar)
                        sousa4 += 1
                    sousa3 += 1
                concentration = 100 * max_sugar / (water + max_sugar)
                if ans[0] < concentration:
                    ans = [concentration, water, max_sugar]
                sousa2 += 1
            sousa1 += 1

        print('{} {}'.format(sum(ans[1:]), ans[2]))


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Time Limit Exceeded

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

max_solvent = 0
max_solute = 0
max_strength = 0.0

for na in range(0, 31):
    for nb in range(0, 31):
        for nc in range(0, 100):
            for nd in range(0, 100):

                solute = nc * C + nd * D
                solvent = na * A + nb * B

                if not (any([na, nb]) and any([nc, nd])):
                    continue

                if (solute + solvent) > F:
                    # print("exceeded")
                    continue

                if (solvent/100) * E < solute:
                    # print("exceeded2")
                    continue

                strength = float(solute) / (solute + solvent)
                # print(strength, solvent+solute, solute)

                if max_strength < strength:
                    max_strength = strength
                    max_solute = solute
                    max_solvent = solute + solvent

print(max_solvent, max_solute)

Submission status: Time Limit Exceeded

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

Water = A*100
Sugar = 0
Consent = 0

# 濃度計算
def calc(water, sugar):
    if water == 0 and sugar == 0:
        return 0
    return (100 * sugar) / (water + sugar) 

def dfs(water, sugar):
    global Water, Sugar, Consent

    if water + sugar > F:
        return 0
    if calc(water, sugar) > calc(100, E):
        return 0

    if Consent < calc(water, sugar):
        Consent = calc(water, sugar)
        Water = water
        Sugar = sugar

    dfs(water + A*100, sugar)
    dfs(water + B*100, sugar)
    dfs(water, sugar + C)
    dfs(water, sugar + D)

dfs(0,0)
print(Water+Sugar, Sugar)

Submission status: Time Limit Exceeded

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

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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
water = [100*a*A + 100*b*B for B in range(t+1) for A in range(s+1) if 100*a*A + 100*b*B != 0]
suger = [c*C + d*D for D in range(v+1) for C in range(u+1)]
ans1 = 0
ans2 = 0
for W in water:
    for S in suger:
        if W + S <= f:
            if W//100*e >= S:
                if concentration < S/(W+S):
                    concentration = S/(W+S)
                    ans1 = W+S
                    ans2 = S
if ans1 == 0:
    ans1 = 100*a
print(ans1,ans2)

Submission status: Time Limit Exceeded

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

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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
water = []
suger = []
for A in range(s+1):
    for B in range(t+1):
        if 100*a*A + 100*b*B != 0:
            water.append(100*a*A + 100*b*B)

for C in range(u+1):
    for D in range(v+1):
        suger.append(c*C + d*D)

ans1 = 0
ans2 = 0
for W in water:
    for S in suger:
        if W + S <= f:
            if W//100*e >= S:
                if concentration < S/(W+S):
                    concentration = S/(W+S)
                    ans1 = W+S
                    ans2 = S
if ans1 == 0:
    ans1 = 100*a
print(ans1,ans2)

Submission status: Time Limit Exceeded

Solution code:

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

amax = F // (100 * A)
bmax = F // (100 * B)
cmax = F // C
dmax = F // D

ans = 0
summ = 0
suge = 0


for a in range(amax+1):

    for b in range(bmax+1):

        for c in range(cmax+1):

            for d in range(dmax+1):


                if 100*A*a + 100*B*b + C*c + D*d <= F and (A*100*a+B*100*b)*E >= 100*(C*c+D*d):

                    if A*100*a+B*100*b+C*c+D*d !=0 and ans < 100*(C*c+D*d)/(A*100*a+B*100*b+C*c+D*d):

                        ans = 100*(C*c+D*d)/(A*100*a+B*100*b+C*c+D*d)
                        summ = A*100*a+B*100*b+C*c+D*d
                        suge = C*c+D*d

if summ == 0:
    summ = 100*A
print (summ,suge)

Submission status: Time Limit Exceeded

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

sugar_water = -1
sugar = -1
concentration = -1

A = 100*A
B = 100*B
max_sugar = (F//100) * E

for a in range(0,F+1,A):
    for b in range(0,F-a+1,B):
        for c in range(0,max_sugar + 1,C):
            for d in range(0,max_sugar-c+1,D):
                tmp_sugar_water = a + b + c + d
                if tmp_sugar_water == 0:
                    continue
                tmp_concentration = 100 * (c + d) / (tmp_sugar_water)
                if tmp_sugar_water <= F and tmp_concentration <= (100 * E) / (100 + E):
                    if tmp_concentration == (100 * E) / (100 + E):
                        concentration = tmp_concentration
                        sugar_water = tmp_sugar_water
                        sugar = c + d
                        break
                    if concentration < tmp_concentration:
                        concentration = tmp_concentration
                        sugar_water = tmp_sugar_water
                        sugar = c + d

print(sugar_water,sugar)

Submission status: Time Limit Exceeded

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

sugar_water = -1
sugar = -1
concentration = -1

A = 100*A
B = 100*B
max_sugar = (F//100) * E

for a in range(0,F+1,A):
    for b in range(0,F-a+1,B):
        for c in range(0,max_sugar + 1,C):
            for d in range(0,max_sugar-c+1,D):
                tmp_sugar_water = a + b + c + d
                if tmp_sugar_water == 0:
                    continue
                tmp_concentration = 100 * (c + d) / (tmp_sugar_water)
                if tmp_sugar_water <= F and tmp_concentration <= (100 * E) / (100 + E):
                    if concentration < tmp_concentration:
                        concentration = tmp_concentration
                        sugar_water = tmp_sugar_water
                        sugar = c + d

print(sugar_water,sugar)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

sugars = []
for i in range(0, F+1):
    for j in range(0, F+1):
        y = i*C + j*D
        if y <= F:
                
            sugars.append(y)
 
water = []
for i in range(0, F+1):
    for j in range(0, F+1):
        x = 100*A*i + 100*B*j
        if x <= F:
               
            water.append(x)
    
sugars.sort()
water.sort()
 

concent = 0
for x in water:
    for y in sugars:
         if x+y > F:
            break
         if x+y > 0 and y/(x+y) <= E/(100+E):
            if y/(x+y) >= concent:
                concent = y/(x+y)
                ans = "{} {}".format(x+y, y)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d, e, f = map(int, input().split())
lisw = []
liss = []
ans = []
cc = f // c
dd = f // d
for ai in range(31):
    for bi in range(31):
        for ci in range(cc):
            for di in range(dd):
                if ai == bi == 0:
                        continue
                if 100 * a * ai + 100 * b * bi + c * ci + d * di <= f:
                    if (c * ci + d * di)/(100 * a * ai + 100 * b * bi) <= e/100:
                        ans.append([(c * ci + d * di)/(100 * a * ai + 100 * b * bi + c * ci + d * di), 100 * a * ai + 100 * b * bi + c * ci + d * di, c * ci + d * di])
ans.sort(reverse=True)
print(ans[0][1], ans[0][2])

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=[]
for i in range(30):
  for j in range(30):
    if i*a*100+j*b*100<=f:
      for p in range(3000):
        for q in range(3000):
          if p*c+q*d<=(i*a+j*b)*e and (p*c+q*d+i*a*100+j*b*100<=f):
            ans.append([p*c+q*d+i*a*100+j*b*100,p*c+q*d])
stack=0
index=0
for i in ans:
  if stack<i[0]/i[1]:
    stack=i[0]/i[1]
    index=i
if index==0:
  print(0,0)
else:
  print(ans[index])

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D,E,F = map(int,input().split())
ans = []
for a in range(F // (A*100) + 1):
    for b in range(F // (B*100) + 1):
        water =  100*a*A + 100*b*B 
        if water <= F:
            for c in range(E*water//100//C+1):
                for d in range(E*water//100//D+1):
                    suger = C*c + D*d
                    if suger+water <= F and E*water//100 >= suger:
                        try:
                            n = suger / (suger+water)
                            ans.append([n,suger+water,suger])
                        except:
                            pass
ans.sort()
print(ans[-1][1],ans[-1][2])