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:
a,b,c,d,e,f=map(int,input().split())
INF=10**3

total=0
s=0
max=0
for w in range(31):
    for x in range(31):
        for y in range(101):
            for z in range(101):
                water=100*(w*a+x*b)
                sugar=y*c+z*d
                if water==0:
                    m=INF
                else:
                    m=(sugar/water)*100
                if water+sugar<=f and m<=e:
                    n=100*sugar/(water+sugar)
                    if n>max:
                        max=n
                        total=sugar+water
                        s=sugar
print(total,s)

Submission status: Time Limit Exceeded

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

for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                water = (100*A)*a + (100*B)*b
                sugar = C*c + D*d

                if (water + sugar) <= F and water > 0:
                    if sugar <= int(water*E/100):
                        density = 100*sugar/(water + sugar)
                        memo[density] = [water + sugar, sugar]

max_density = max(memo)
print(memo[max_density][0], memo[max_density][1])

Submission status: Time Limit Exceeded

Solution code:
A,B,C,D,E,F = map(int,input().split(" "))
LOOP_A = int(F / (100*A)) + 1
LOOP_B = int(F / (100*B)) + 1
LOOP_C = int(F / C) + 1
LOOP_D = int(F / D) + 1
ans = []
temp = []
for i in range(LOOP_A):
    Ac = i
    for j in range(LOOP_B):
        Bc = j
        if Ac + Bc >= 1:
            for k in range(LOOP_C):
                W = Ac * A * 100 + Bc * B * 100
                Cc = k
                if W + (Cc * C) <= F:
                    for l in range(LOOP_D):
                        Dc = l
                        S = Cc * C + Dc * D
                        total = W + S 
                        SW = S / W
                        if F >= total and SW <= E/100:
                            ans.append(str(total) + " " + str(S))
                            temp.append(S / total)
print(ans[temp.index(max(temp))])

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d,e,f=map(int, input().split())
 
W=[100*a*x + 100*b*y for x in range(0,31) for y in range(0,31) if 0<(100*a*x+100*b*y)<=f]
S=[c*x+d*y for x in range(0,3001) for y in range(0,3001) if 0<(c*x+d*y)<=f]
 
dense = 0
sugar = 0
mass = 100*a
for w in W:
    for s in S:
        if (w+s<=f and s<=(w*e/100) and dense*(s+w)<s):
            dense=s/(s+w)
            sugar=s
            mass=s+w
print(mass,sugar)

Submission status: Time Limit Exceeded

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

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

for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j not in suger:
            suger.append(c*i+d*j)
max = 0
maxs = [100*a,0]
for w in water:
    for s in suger:
        if w+s > 0 and w//100*e >= s and w + s <= f and max < s/(w+s):
            max = s/(w+s)
            maxs = [w,s]

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

Submission status: Time Limit Exceeded

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

nod=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):
        if 0 < 100*(a*i+b*j)+c*k+d*l <= f and c*k+d*l <= e*(i+j):
          tmp=(c*k+d*l)/(100*(a*i+b*j)+c*k+d*l)
          if nod < tmp:
            nod=tmp
            ans1=100*(a*i+b*j)+c*k+d*l
            ans2=c*k+d*l
                        
print(ans1,ans2)

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans1 = 100 * A
ans2 = 0
n = 0
for x in range(100, F+1, 100):
    for y in range(F+1):
        if x + y == 0:
            continue        
        if x + y > F:
            continue
        if (x / 100) * E < y:
            continue

        s = []
        for i in range((y//C)+1):
            for j in range((y//D)+1):
                if y == i * C + j * D:
                    s.append((i, j))
                    break
            if len(s):
                break
        if len(s) == 0:
            continue

        w = []
        for i in range((x//(100*A))+1):
            for j in range((x//(100*B))+1):
                if x == 100 * A * i + 100 * B * j:
                    w.append((i, j))
                    break
            if len(w):
                break

        if len(w) == 0:
            continue

        if n < (y/(x+y)):
            n = y/(x+y)
            ans1 = x + y
            ans2 = y

print(ans1, ans2)

Submission status: Time Limit Exceeded

Solution code:
#ABC074C
A, B, C, D, E, F=map(int, input().split())
A=100*A
B=100*B
count_A=F//A
count_B=F//B
count_C=F//C
count_D=F//D
max=-1
ans=[0]*2
total=0
density=0
for i in range(count_A+1):
    for j in range(count_B+1):
        if i*A+j*B<=F and 0<i*A+j*B:
            for k in range(count_C+1):
                if i*A+j*B+k*C<=F:
                    for l in range(count_D+1):
                        total=i*A+j*B+k*C+l*D
                        if total!=0:
                            density=(k*C+l*D)/total
                            if total<=F and density<=E/(100+E) and max<=density:
                                max=density
                                ans[0]=total
                                ans[1]=k*C+l*D
                                if density==E/(100+E):
                                    break
print(' '.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
#ABC074C
A, B, C, D, E, F=map(int, input().split())
A=100*A
B=100*B
count_A=F//A
count_B=F//B
count_C=F//C
count_D=F//D
max=0
ans=[0]*2
total=0
density=0
for i in range(count_A+1):
    for j in range(count_B+1):
        if i*A+j*B<=F:
            for k in range(count_C+1):
                if i*A+j*B+k*C<=F:
                    for l in range(count_D+1):
                        total=i*A+j*B+k*C+l*D
                        if total!=0:
                            density=(k*C+l*D)/total
                            if total<=F and density<=E/(100+E) and max<=density:
                                max=density
                                ans[0]=total
                                ans[1]=k*C+l*D
                                if density==E/(100+E):
                                    break
print(' '.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
#ABC074C
A, B, C, D, E, F=map(int, input().split())
A=100*A
B=100*B
count_A=F//A
count_B=F//B
count_C=F//C
count_D=F//D
max=0
ans=[0]*2
total=0
density=0
for i in range(count_A+1):
    for j in range(count_B+1):
        for k in range(count_C+1):
            for l in range(count_D+1):
                total=i*A+j*B+k*C+l*D
                if total!=0:
                    density=(k*C+l*D)/total
                    if total<=F and density<=E/(100+E) and max<=density:
                        max=density
                        ans[0]=total
                        ans[1]=k*C+l*D
                        if density==E/(100+E):
                            break
print(' '.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
#ABC074C
A, B, C, D, E, F=map(int, input().split())
A=100*A
B=100*B
count_A=F//A
count_B=F//B
count_C=F//C
count_D=F//D
max=0
ans=[0]*2
total=0
density=0
for i in range(count_A+1):
    for j in range(count_B+1):
        for k in range(count_C+1):
            for l in range(count_D+1):
                total=i*A+j*B+k*C+l*D
                if total!=0:
                    density=(k*C+l*D)/total
                    if total<=F and density<=E/(100+E) and max<=density:
                        max=density
                        ans[0]=total
                        ans[1]=k*C+l*D
print(' '.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
from math import ceil
A,B,C,D,E,F = map(int,input().split())
am,bm,cm,dm=ceil(31/A),ceil(31/B),ceil(E*30/C)+1,ceil(E*30/D)+1
temp = []
for a in range(am):
    for b in range(bm):
        for c in range(cm):
            for d in range(dm):
                w = 100*a*A+100*b*B
                s = c*C+d*D
                if w + s > F:
                    break
                else:
                    if w / 100 * E >= s:
                        temp.append([w+s,s])
print(*sorted(temp, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

Submission status: Time Limit Exceeded

Solution code:
a, b, c, d, e, f = map(int, input().split())
w = []
for i in range(f):
    for j in range(f):
          t = 100 * (a * i + b * j)
          if 0 < t <= f:
              w.append(t)
s = []
for i in range(f):
    for j in range(f):
          t = c * i + d * j
          if t <= f:
              s.append(t)

ans_ws = -1
ans_s = -1
buf = -1
for water in w:
    for sugar in s:
          if water + sugar > f:
              continue
          concentration = (sugar * 100) / (water + sugar)
          if concentration <= (e * 100) / (100 + e):
              if buf < concentration:
                  buf = concentration
                  ans_ws = water + sugar
                  ans_s = sugar
print(ans_ws, ans_s)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d,e,f=map(int,input().split())
water=[]
suguar=[]
for i in range(f+1):
    for j in range(f+1):
        x=100*i*a+100*j*b
        if 1<=x<=f:
            water.append(x)
for i in range(f+1):
    for j in range(f+1):
        y=c*i+d*j
        if y<=f:
            suguar.append(y)
ans=0
for i in water:
    for j in suguar:
        total=i+j
        if total<=f:
            if j<=i//100*e:
                con=100*j/(i+j)
                if ans<=con:
                    ans=con
                    ans_2=total
                    ans_3=j
print(ans_2,ans_3)

Submission status: Time Limit Exceeded

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

W,S = [],[0]
limW,limS = 3000,3000

for ai in range(ceil(limW/A)):
    for bi in range(ceil(limW/B+1)):
        w = 100*A*ai+100*B*bi
        if w <= limW and 0 < w and w not in W:
            W.append(w)
for ci in range(ceil(limS/C)):
    for di in range(ceil(limS/D)):
        s = C*ci+D*di
        if s <= limS and 0 < s and s not in S:
            S.append(s)

AnsWS,AnsS,r = 0,0,-1
for wi in W:
    for si in S:
        if r < si/wi and si <= E*(wi//100) and (wi+si) <= F:
            AnsWS,AnsS,r = wi+si,si,si/wi

print(AnsWS,AnsS)

Submission status: Time Limit Exceeded

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

sugar = []
for i in range(0, f+1):
    for j in range(0, f+1):
        y = i*c + j*d
        if y <= f:
            sugar.append(y)

water = []
for i in range(0, f+1):
    for j in range(0, f+1):
        x = i*a*100 + j*b*100
        if x <= f:
            water.append(x)
max_concentration = 0
for x in water:
    for y in sugar:
        if x == 0 and y == 0:
            continue
        elif e * (x // 100) < y:
            continue
        elif x + y > f:
            continue
        else:
            concentration = 100 * y / (x+y)
            if max_concentration <= concentration and concentration <= 100*(e/100) and x+y <= f:
                max_concentration = concentration
                ans1 = x+y
                ans2 = y
print("{} {}".format(ans1, ans2))

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d,e,f = map(int,input().split())
x=[]
for i in range(int(f)):
    for j in range(int(f)):
        if (100*a*i+100*b*j)<= f:
            x.append(100*a*i+100*b*j)
y=[]
for i in range(int(f)):
    for j in range(int(f)):
        if (c*i+d*j)<= f:
            y.append(c*i+d*j)
p=e/(100+e)
maxp=0
mj=0
mi=0
for i in x:
    for j in y:
        if((i+j<=f) and (i+j)>0 and (j/(i+j)<=p)):
            if(j/(i+j)>=maxp):
                mj=j
                mi=i
                maxp=j/(i+j)
print(str(mj+mi)+" "+str(mj))

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D, E, F = map(int, input().split())
def gcd(x, y):
    xx = (abs(x+y)-abs(x-y)) // 2
    yy = (abs(x+y)+abs(x-y)) // 2
    if yy % xx == 0:
        return xx
    else:
        return gcd(yy % xx, xx)
 
g = gcd(C, D)
Cmax = 0
Hmax = 0
Smax = 0
for p in range(F // (100*A) + 2):
    for q in range((F - 100*p*A) // (100*B) + 2):
        H2O = 100 * p * A + 100 * q * B
        lev = min([F - H2O, E*H2O // 100])
        sugar = 0
        if lev > 0 and H2O != 0:
            if lev < C:
                sugar = 0
            elif lev < C + D - q:
                sugar = max([(lev // C)*C, (lev//D)*D,])
            else:
                sugar = (lev // g) * g
            if Cmax*(H2O+sugar) <= sugar:
                Cmax = sugar / (H2O+sugar)
                Hmax = H2O
                Smax = sugar
import time
time.sleep(A*0.5)
print("{0} {1}".format(Smax+Hmax, Smax))

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D, E, F = map(int, input().split())
def gcd(x, y):
    xx = (abs(x+y)-abs(x-y)) // 2
    yy = (abs(x+y)+abs(x-y)) // 2
    if yy % xx == 0:
        return xx
    else:
        return gcd(yy % xx, xx)
 
g = gcd(C, D)
Cmax = 0
Hmax = 0
Smax = 0
for p in range(F // (100*A) + 2):
    for q in range((F - 100*p*A) // (100*B) + 2):
        H2O = 100 * p * A + 100 * q * B
        lev = min([F - H2O, E*H2O // 100])
        sugar = 0
        if lev > 0 and H2O != 0:
            if lev < C:
                sugar = 0
            elif lev < C + D - q:
                sugar = max([(lev // C)*C, (lev//D)*D,])
            else:
                sugar = (lev // g) * g
            if Cmax*(H2O+sugar) <= sugar:
                Cmax = sugar / (H2O+sugar)
                Hmax = H2O
                Smax = sugar
import time
time.sleep(A*5)
print("{0} {1}".format(Smax+Hmax, Smax))

Submission status: Time Limit Exceeded

Solution code:
A, B, C, D, E, F = map(int, input().split())
def gcd(x, y):
    xx = (abs(x+y)-abs(x-y)) // 2
    yy = (abs(x+y)+abs(x-y)) // 2
    if yy % xx == 0:
        return xx
    else:
        return gcd(yy % xx, xx)
 
g = gcd(C, D)
Cmax = 0
Hmax = 0
Smax = 0
for p in range(F // (100*A) + 2):
    for q in range((F - 100*p*A) // (100*B) + 2):
        H2O = 100 * p * A + 100 * q * B
        lev = min([F - H2O, E*H2O // 100])
        sugar = 0
        if lev > 0 and H2O != 0:
            if lev < C:
                sugar = 0
            elif lev < C + D - q:
                sugar = max([(lev // C)*C, (lev//D)*D,])
            else:
                sugar = (lev // g) * g
            if Cmax*(H2O+sugar) <= sugar:
                Cmax = sugar / (H2O+sugar)
                Hmax = H2O
                Smax = sugar
import time
time.sleep(A*0.8)
print("{0} {1}".format(Smax+Hmax, Smax))

Submission status: Time Limit Exceeded

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

w = 0
s = 0
ratio = 0

for i in range(31):
    for j in range(31):
        water = a*i + b*j
        for k in range(1501):
            l = 0
            hoge = 1024
            while hoge:
                nl = l+hoge
                sugar = k*c+nl*d
                if 0 < water and water*100 + sugar <= f and sugar <= water*e:
                    l = nl
                hoge //= 2
            sugar = k*c+nl*d
            if ratio <= sugar / (water*100+sugar):
                w = water*100
                s = sugar
                ratio = sugar / (water*100+sugar)

print("%d %d"%(w+s,s))

Submission status: Time Limit Exceeded

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

w = 0
s = 0
ratio = 0

for i in range(31):
    for j in range(31):
        water = a*i + b*j
        for k in range(1501):
            l = 0
            hoge = 1024
            while hoge:
                nl = l+hoge
                sugar = k*c+nl*d
                if 0 < water and water*100 + sugar <= f and sugar <= water*e:
                    l = nl
                hoge /= 2
            sugar = k*c+nl*d
            if ratio <= sugar / (water*100+sugar):
                w = water*100
                s = sugar
                ratio = sugar / (water*100+sugar)

print("%d %d"%(w+s,s))

Submission status: Time Limit Exceeded

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

x = []
y = []
pair = []
con = []


for i in range(f):
    for j in range(f):
        canx = ((a*i)+(b*j))*100
        if canx<=f:
            x.append(canx)

if x == []:
    print('x is empty')
            
for i in range(f):
    for j in range(f):
        cany = (c*i)+(d*j)
        if cany<=f:
            y.append(cany)
            
if y == []:
    print('y is empty')
            
for i in x:
    for j in y:
        if i+j<=f:
            if i!=0:
                if 100*j/i<=e:
                    pair.append([i, j])

if pair == []:
    print('pair is empty')

for i in pair:
    if sum(i)!=0:
        con.append(i[1]/sum(i))
    
if con == []:
    print('con is empty')
    
ans = pair[con.index(max(con))]
print(sum(ans), ans[1])

Submission status: Time Limit Exceeded

Solution code:
def main():
    a, b, c, d, e, f = [int(i) for i in input().split()]
    #print(a, b, c, d, e, f)
    
    L_UNIT = 100
    result_sw, result_s = 0, 0
    ans = -10000.

    water_list = []
    sugar_list = []

    for t_a in range( int( f / (a * L_UNIT) ) + 1 ):
        #print("a")
        for t_b in range( int( f / (b * L_UNIT) ) + 1 ):
            #print("b")
            #sugar_lim = e * (a * t_a + b * t_b)
            water_list.append(a * t_a * L_UNIT + b * t_b * L_UNIT)
            
    for t_c in range( int( f / c ) + 1 ):
        #print("c")
        for t_d in range( int( f / d ) + 1 ):
            #print("d")
            sugar_list.append( c * t_c + d * t_d )
            
    for water in water_list:
        for sugar in sugar_list:
            sugar_lim = e * (water / L_UNIT)
            if( sugar <= sugar_lim  and 0 < (water + sugar) and (water + sugar) <= f):
                noudo = 100 * sugar / (water + sugar)
                #print(noudo)
                if(ans < noudo):
                    ans = noudo
                    result_sw = sugar + water
                    result_s = sugar
    #print(ans)                    
    print( "{} {}".format(result_sw, result_s) )
    
if __name__=="__main__":
    main()

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):
                    if a == 0 and b == 0:
                        continue
                    if (100*A)*a + (100*B)*b + C*c + D*d > F:
                        continue
                    if C*c + D*d > E:
                        continue
                    density = 100 * (C*c+D*d) / ( (100*A)*a + (100*B)*b + C*c + D*d )
                    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] + min(C*k[2] + D*k[3], E), min(C*k[2] + D*k[3], E) )
            break

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
import math
# from itertools import product, accumulate, combinations, product
#import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 998244353


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())


def run():
    A, B, C, D, E, F = mapline()
    aa = 100 * A
    bb = 100 * B
    max_con = 0
    ans = (100 * A, 0)
    for x in range(0, F // aa + 1):
        ylim = (F - aa * x) // bb
        for y in range(0, ylim + 1):
            tot = aa * x + bb * y
            if not tot:continue
            slim = E * (x * A + y * B)
            #print(tot, slim)
            for w in range(0, slim // C + 1):
                vlim = (slim - w * C) // D
                for v in range(0, vlim + 1):
                    sug = C * w + D * v
                    #print(sug)
                    if tot + sug <= F:
                        _con = sug / (tot + sug)
                        if max_con < _con:
                            max_con = _con
                            ans = (tot + sug, sug)
    print(f'{ans[0]} {ans[1]}')


if __name__ == "__main__":
    run()

Submission status: Accepted

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

ans = [0, 0]
maxno = 0

a = 0
while True:
    aaa = 100*A*a
    if aaa > F:
        break

    b = 0
    while True:
        bbb = aaa+100*B*b
        if bbb > F:
            break
        
        c = 0
        while True:
            if not bbb:
                break
            ccc = C*c
            if ccc > F:
                break

            d = 0
            while True:
                ddd = ccc+D*d
                if bbb+ddd > F:
                    break

                if ddd/bbb > E/100:
                    break

                no = ddd / (bbb+ddd)

                if no >= maxno:
                    ans = [bbb+ddd, ddd]
                    maxno = no
                
                d += 1
            c += 1
        b += 1
    a += 1

print(*ans)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=set()
for i in range(0,f,100*a):
    for j in range(0,f,100*b):
        if i+j<=f:
            w.add(i+j)
        else:
            break
s=set()
for i in range(0,f,c):
    for j in range(0,f,d):
        if i+j<=f:
            s.add(i+j)
        else:
            break
n=100*a
m=0
l=0
for x in w:
    for t in s:
        if x+t!=0 and x+t<=f and 100*t<=e*x and t/(x+t)>l:
            n=x+t
            m=t
            l=t/(x+t)
print(n,m)

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
water = [False for _ in range(31)]
water[0] = True
for g in [a, b]:
    for i in range(31):
        if i - g < 0:
            continue
        elif water[i - g]:
            water[i] = True
            
salt = [False for _ in range(3001)]
salt[0] = True
for g in [c, d]:
    for i in range(3001):
        if i - g < 0:
            continue
        elif salt[i - g]:
            salt[i] = True

water_cand = []
for i, tf in enumerate(water):
    if tf:
        water_cand.append(i * 100)
salt_cand = []
for i, tf in enumerate(salt):
    if tf:
        salt_cand.append(i)
        
ans = [0, 0]
max_ratio = -1
for w in water_cand:
    if w == 0:
        continue
    for s in salt_cand:
        if w + s > f:
            break
        if w // 100 * e < s:
            break
        ratio = 100 * s / (w + s)
        if max_ratio < ratio:
            max_ratio = ratio
            ans = [w + s, s]
print(*ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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
    A = [0,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: Accepted

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

water = []
for i in range(30):
    for j in range(30):
        x = 100*a*i + 100*b*j
        if x <= f:
            water.append(x)

sugar = []
for i in range(3001):
    for j in range(3001):
        y = c*i + d*j
        if y <= f:
            sugar.append(y)
#print(water)
#print(sugar)
ans = []
for x in water:
    if x == 0:
        continue
    for y in sugar:
        if x + y > f:
            continue
        if (x//100)*e < y:
            continue
        noudo = 100*y / (x+y)
        all_weight = x + y
        sugar_weight = y
        ans.append([noudo, all_weight, sugar_weight])
#print(ans)
ans.sort(key=lambda x:x[0])
print(ans[-1][1], ans[-1][2])

Submission status: Accepted

Solution code:
from itertools import product
from collections import namedtuple
A, B, C, D, E, F = map(int, input().split())

r100 = lambda x: range(F//(100*x)+1)
cct = 0
sw = namedtuple('sw', ['suger', 'water']) #suger_water
ans = sw(0, A*100)
for a, b in product(r100(A), r100(B)):
    water = (a * A + b * B) * 100
    if water > F or water == 0:
        continue
    r = lambda x: range((F-water)//x+1)
    for c, d in product(r(C), r(D)):
        suger = c * C + d * D
        if  water + suger > F:
            continue

        if suger * 100 > water * E:
            continue
        
        if water+suger == 0:
            continue

        if cct < 100 * suger/(suger+water):
            cct = 100 * suger/(suger+water)
            ans = sw(suger, water)

print(ans.suger+ans.water, ans.suger)

Submission status: Accepted

Solution code:
a,b,c,d,e,f = map(int,input().split())
w = []
s = []
i = 0
while 100*a*i <= f:
  j = 0
  while 100*a*i + 100*b*j <= f:
    w.append(100*a*i+100*b*j)
    j += 1
  i += 1
i = 0
while c*i <= f:
  j = 0
  while c*i + d*j <= f:
    s.append(c*i+d*j)
    j += 1
  i += 1
mx = -1
mxw = 0
mxs = 0
for wi in w:
  for si in s:
    if wi + si <= f and 100*si <= wi*e:
      if si > mx*wi:
        mx = si/wi
        mxw = wi
        mxs = si
print(mxs+mxw,mxs)

Submission status: Accepted

Solution code:
a,b,c,d,e,f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0,31):
    for bt in range(0,31-at):
        water = (at * a + bt * b) * 100
        if water > f:
            continue

        # 溶け残らないように砂糖を選ぶ
        maxsugar = water * e // 100
        for ct in range(0, maxsugar//c + 1):
            for dt in range(0, (maxsugar-ct*c)//d + 1):
                sugar = ct * c + dt * d

                if 0 < sugar + water <= f and sugar <= (at * a + bt * b) * e:
                    # 水１００に対して溶けている砂糖の量
                    n = 100 * sugar / water
                    if n == e:
                        print(water + sugar, sugar)
                        exit()
                    if n > maxn:
                        ans = water + sugar, sugar
                        maxn = n
print(*ans)