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: Wrong Answer

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+b*B+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=(a*A+b*B+c*C+d*D,c*C+d*D)

print(*ans)

Submission status: Wrong Answer

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+b*B+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=(a*A+b*B+c*C+d*D,c*C+d*D)

print(ans)

Submission status: Wrong Answer

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+b*B+c*C+d*D<=F and (a+b)*E>=c+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=(a*A+b*B+c*C+d*D,c*C+d*D)

print(ans)

Submission status: Wrong Answer

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(30):
    for b in range(15):
        for c in range(100):
            for d in range(100):
                if a*A+b*B+c*C+d*D<=F and (a+b)*E>=c+d and a+b>0:
                    if m<(c+d)/(a+b):
                        m=(c+d)/(a+b)
                        ans=(a+b+c+d,c+d)

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
ans = 0
l = [0, 0]
for i in range(f):
  for j in range(f):
    x = 100*a*j + 100*b*i
    y = (100*a*j)//100*(e//c)*c + (100*b*i)//100*(e//d)*d
    if x + y <= f and (x>0 or y>0):
      if ans <= 100*y/(x+y):
        #print(ans, 100*y/(x+y))
        l = [x+y, y]
        ans = 100*y/(x+y)
    else:
      continue
print(" ".join(map(str, l)))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
d=0
ans=(0,0)
for x in range(F//(100*A)+1):
    for y in range((F-x*100*A)//(100*B)+1):
        if x+y==0:
            continue
        for z in range((F-x*100*A-y*100*B)//C+1):
            for w in range((F-x*100*A-y*100*B-z*C)//D+1):                
                if (x*A+y*B)*E>=(z*C+w*D) and d<100*(z*C+w*D)/(100*(x*A+y*B)+(z*C+w*D)):                    
                    d=100*(z*C+w*D)/(100*(x*A+y*B)+(z*C+w*D))
                    # print((x,y,z,w))                
                    # print((100*(x*A+y*B)+(z*C+w*D),(z*C+w*D),d))
                    ans=(100*(x*A+y*B)+(z*C+w*D),(z*C+w*D))

print(*ans)

Submission status: Wrong Answer

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 = int(math.ceil(water_max / (100*a)))
b_max = int(math.ceil(water_max / (100*b)))
water_gaps = []
for i in range(a_max+1):
  for j in range(b_max+1):
    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 = int(math.ceil(sugar_max / c))
d_max = int(math.ceil(sugar_max / d))
sugar_gaps = []
for k in range(c_max+1):
  for l in range(d_max+1):
    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: Wrong Answer

Solution code:



def main()->None:
    # 他の人の回答見た。
    # https://atcoder.jp/contests/abc074/submissions/8698084
    a, b, c, d, e, f = map(int, input().split())

    max_sugar = 0
    max_water = 100 * a
    max_concentration = 0.0
    a_limit = f // (100 * a)
    for i in range(a_limit+1):
        b_limit = (f - 100 * a * i) // (100 * b)
        for j in range(b_limit + 1):
            if i == 0 and j == 0: continue
            sugar_limit = min(e * (a * 1 + b * j), f - 100 * ( a * i + b * j ))

            sugar = 0
            for g in range(sugar_limit // c + 1):
                h = (sugar_limit - g * c ) // d
                temp_sugar = g * c + h * d
                sugar = max(sugar, temp_sugar)
            temp_cons = sugar / (sugar + 100 * (a * i + b * j))
            if temp_cons > max_concentration:
                max_concentration = temp_cons
                max_water = 100 * (a * i + b * j)
                max_sugar = sugar
    print("{} {}".format(max_water + max_sugar, max_sugar))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:



def main()->None:
    # 濃度をマックスにしたい
    a, b, c, d, e, f = map(int, input().split())

    max_solute = 0
    max_solvent = 0
    max_concentration = 0
    range_N = range(f+1)
    for i in range_N:
        for j in range_N:
            if i == 0 and j == 0 : continue
            water = (100 *  a * i ) + ( 100 * b * j ) # 投入する水の量
            solvent = ( c * i ) + ( d * j )# 溶かす砂糖の量
            solute = water + solvent
            concentration = solvent / solute
            if (solute >= f) or (solvent >= (water/100) * e):
                continue
            if  concentration > max_concentration:
                max_solvent = solvent
                max_solute = solute
                max_concentration = concentration
    print(max_solute, " ", max_solvent)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:



def main()->None:
    # 濃度をマックスにしたい
    a, b, c, d, e, f = map(int, input().split())

    max_solute = 0
    max_solvent = 0
    max_concentration = 0
    range_N = range(f+1)
    for i in range_N:
        for j in range_N:
            if i == 0 and j == 0 : continue
            water = (100 *  a * i ) + ( 100 * b * j ) # 投入する水の量
            solvent = ( c * i ) + ( c * j )# 溶かす砂糖の量
            solute = water + solvent
            concentration = solvent / (solvent + solute)
            if solute > f or solvent > (water/100) * e:
                            break
            if  max_solvent <  solvent <= (water/100) * e and concentration > max_concentration:
                max_solvent = solvent
                max_solute = solute
                max_concentration = concentration

    print(max_solute, " ", max_solvent)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:



def main()->None:
    # 濃度をマックスにしたい
    a, b, c, d, e, f = map(int, input().split())

    solute = 0
    max_solvent = 0
    range_N = range(f+1)
    for i in range_N:
        for j in range_N:
            water = 100 * ( a * i +  b * j ) # 投入する水の量
            solvent = c * i + c * j # 溶かす砂糖の量
            if  max_solvent <  solvent <= (water/100) * e:
                max_solvent = solvent
                solute = water + solvent
            if water + solvent > f:
                break

    print(solute, " ", max_solvent)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:



def main()->None:
    # 濃度をマックスにしたい
    a, b, c, d, e, f = map(int, input().split())

    solute = 0
    max_solvent = 0
    range_N = range(f+1)
    for i in range_N:
        for j in range_N:
            water = 100 * a * i + 100 * b * j # 投入する水の量
            solvent = c * i + c * j # 溶かす砂糖の量
            if water + solvent > f:
                break
            if solvent > max_solvent and solvent <= (water/100) * e:
                max_solvent = solvent
                solute = water + solvent

    print(solute, " ", max_solvent)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:



def main()->None:
    # 濃度をマックスにしたい
    a, b, c, d, e, f = map(int, input().split())

    solute = 0
    max_solvent = 0
    range_N = range(f)
    for i in range_N:
        for j in range_N:
            water = 100 * a * i + 100 * b * j # 投入する水の量
            solvent = c * i + c * j # 溶かす砂糖の量
            if water + solvent > f:
                break
            if solvent > max_solvent and solvent <= e:
                max_solvent = solvent
                solute = water + solvent

    print(solute, " ", max_solvent)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

sugar = 0
ans1 = 100 * a

max_a = f // (a * 100)


#操作１
for i in range(1, max_a + 1):
    max_b = (f - 100 * i * a) // (100 * b)
    #操作２
    for j in range(max_b +1):
        water = 100 * a * i + 100 * b * j
        #可能な砂糖の量
        max_sugar = (a * i + b * j) * e
        #最大濃度に近い
        if water + max_sugar <= f:
            max_c = max_sugar // c
            for k in range(max_c + 1):
                max_d = (max_sugar - k * c) // d
                if sugar < (k * c + max_d * d):
                    sugar = (k * c + max_d * d)
                    ans1 = water + sugar
        #濃度を薄める
        else:
            max_sugar = f - water
            min_sugar = c
            if min_sugar < e:
                for k in range(e // min_sugar + 1):
                    max_d = (max_sugar - k * c) // d
                    if sugar < (k * c + max_d * d):
                        sugar = (k * c + max_d * d)
                        ans1 = water + sugar

print(ans1,sugar)

Submission status: Wrong Answer

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

sugar = 0
ans1 = 100 * a

max_a = f // (a * 100)


#操作１
for i in range(1, max_a + 1):
    max_b = (f - 100 * i * a) // (100 * b)
    #操作２
    for j in range(max_b +1):
        water = 100 * a * i + 100 * b * j
        #可能な砂糖の量
        max_sugar = (a * i + b * j) * e
        #最大濃度に近い
        if water + max_sugar <= f:
            max_c = max_sugar // c
            for k in range(max_c + 1):
                max_d = (max_sugar - k * c) // d
                if sugar < (k * c + max_d * d):
                    sugar = (k * c + max_d * d)
                    ans1 = water + sugar
        #濃度を薄める
        else:
            max_sugar = f - water
            min_sugar = (a * i + b * j) * c
            if min_sugar < e:
                for k in range(e // min_sugar + 1):
                    max_d = (max_sugar - k * c) // d
                    if sugar < (k * c + max_d * d):
                        sugar = (k * c + max_d * d)
                        ans1 = water + sugar

print(ans1,sugar)

Submission status: Wrong Answer

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

sugar = 0
ans1 = 100 * a

max_a = f // (a * 100)


#操作１
for i in range(max_a + 1):
    max_b = (f - 100 * i * a) // (100 * b)
    #操作２
    for j in range(max_b +1):
        water = 100 * a * i + 100 * b * j
        #可能な砂糖の量
        max_sugar = (a * i + b * j) * e
        #最大濃度に近い
        if water + max_sugar <= f:
            max_c = max_sugar // c
            for k in range(max_c + 1):
                max_d = (max_sugar - k * c) // d
                if sugar < (k * c + max_d * d):
                    sugar = (k * c + max_d * d)
                    ans1 = water + sugar
        #濃度を薄める
        else:
            max_sugar = f - water
            min_sugar = (a * i + b * j) * c
            if min_sugar < e:
                for k in range(e // min_sugar + 1):
                    max_d = (max_sugar - k * c) // d
                    if sugar < (k * c + max_d * d):
                        sugar = (k * c + max_d * d)
                        ans1 = water + sugar

print(ans1,sugar)

Submission status: Wrong Answer

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

ans1 = 0
ans2 = 0

mizu = []
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 != 0:
			mizu.append(100*a*i+100*b*j)
mizu = set(mizu)
mizu = sorted(mizu)

satou = []
for i in range(f//c+1):
	for j in range(f//d+1):
		if c*i+d*j <= f/100*e:
			satou.append(c*i+d*j)
satou = set(satou)
satou = sorted(satou)

maxnou = 0
for i in range(len(mizu)):
	for j in range(len(satou)):
		if satou[j]+mizu[i] <= f:
			#print(satou[j],mizu[i],satou[j]/mizu[i])
			if maxnou < satou[j]/mizu[i] <= e/100:
				#print(satou[j],mizu[i])
				ans1 = satou[j]+mizu[i]
				ans2 = satou[j]
				maxnou = satou[j]/mizu[i]
		
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int,input().split())
pmax = f//(100*a)
qmax = f//(100*b)
rmax = f//c
smax = f//d
max_cont = 0.
amt_all = 0
amt_sugar = 0
for p in range(pmax+1):
    for q in range(qmax+1):
        for r in range(rmax+1):
            for s in range(smax+1):
                if p==0 & q==0:
                    continue
                tmp_all = 100*a*p+100*b*q+c*r+d*s
                tmp_sugar = c*r+d*s
                if (tmp_all<=f)&(100*tmp_sugar/(tmp_all-tmp_sugar)<=e):
                    if (tmp_sugar/tmp_all)>max_cont:
                        max_cont = tmp_sugar/tmp_all
                        amt_all = tmp_all
                        amt_sugar = tmp_sugar
print(amt_all, amt_sugar)

Submission status: Wrong Answer

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
            E = f - water * 100
            if E <= 0:
                continue
            aa = bisect_right(lis, 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()

Submission status: Wrong Answer

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
            for E in range(1, e + 1):
                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()

Submission status: Wrong Answer

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()

Submission status: Wrong Answer

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 * 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()

Submission status: Wrong Answer

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 // c + 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 * 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()

Submission status: Wrong Answer

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(3001):
        for k in range(3001):
            lis.append(c * i + d * k)
    lis = list(set(lis))
    lis.sort()
    ans = [0, 0]
    for i in range(31):
        for k in range(31):
            water = (a * i + b * k)
            if water * e <= f - water * 100:
                aa = bisect_right(lis, water * e) - 1
                if aa == -1:
                    continue
                aa = lis[aa]
                if ans[0] == 0:
                    ans = [water * 100 + aa, aa]
                else:
                    if ans[1] / ans[0] < aa / (water * 100 + aa):
                        ans = [water * 100 + aa, aa]
    print(*ans)

    return


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