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:
a, b, c, d, e, f = list(map(int, input().split()))
res = [0, 0]
max_nodo = 0
max_anum = f // (a*100)+1
for anum in range(max_anum):
    max_bnum = (f - anum*100) // (b*100) + 1
    for bnum in range(max_bnum):
        try:
            max_cnum = (f - anum*100 - bnum*100) // c + 1
        except:
            max_cnum = 1
        water = anum*a*100 + bnum*b*100
        if anum == 0 and bnum == 0:
            break
        for cnum in range(max_cnum):
            try:
                max_dnum = (f - anum*100 - bnum*100 - cnum*c) // d + 1
            except:
                max_dnum = 1
            for dnum in range(max_dnum):
                suger = cnum*c + dnum*d
                nodo = (suger*100) / (water + suger)
                if nodo > (e*100)/(100+e) or water + suger > f:
                    break
                if max_nodo < nodo:
                    max_nodo = nodo
                    res[0] = water + suger
                    res[1] = suger
print(str(res[0]) + " " + str(res[1]))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
res = [0, 0]
max_nodo = 0
max_anum = f // (a*100)+1
for anum in range(max_anum):
    max_bnum = (f - anum*100) // (b*100) + 1
    for bnum in range(max_bnum):
        try:
            max_cnum = (f - anum*100 - bnum*100) // c + 1
        except:
            max_cnum = 1
        water = anum*a*100 + bnum*b*100
        if anum == 0 and bnum == 0:
            break
        for cnum in range(max_cnum):
            if d == 0:
                break
            max_dnum = (f - anum*100 - bnum*100 - cnum*c) // d + 1
            for dnum in range(max_dnum):
                suger = cnum*c + dnum*d
                nodo = (suger*100) / (water + suger)
                if nodo > (e*100)/(100+e) or water + suger > f:
                    break
                if max_nodo < nodo:
                    max_nodo = nodo
                    res[0] = water + suger
                    res[1] = suger
print(str(res[0]) + " " + str(res[1]))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
res = [0, 0]
max_nodo = 0
max_anum = f // (a*100)+1
for anum in range(max_anum):
    max_bnum = (f - anum*100) // (b*100) + 1
    for bnum in range(max_bnum):
        max_cnum = (f - anum*100 - bnum*100) // c + 1
        water = anum*a*100 + bnum*b*100
        if anum == 0 and bnum == 0:
            break
        for cnum in range(max_cnum):
            max_dnum = (f - anum*100 - bnum*100 - cnum*c) // d + 1
            for dnum in range(max_dnum):
                suger = cnum*c + dnum*d
                nodo = (suger*100) / (water + suger)
                if nodo > (e*100)/(100+e) or water + suger > f:
                    break
                if max_nodo < nodo:
                    max_nodo = nodo
                    res[0] = water + suger
                    res[1] = suger
print(str(res[0]) + " " + str(res[1]))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
res = [0, 0]
max_nodo = 0
max_anum = f // (a*100)+1
for anum in range(max_anum):
    max_bnum = (f - anum*100) // (b*100) + 1
    for bnum in range(max_bnum):
        max_cnum = (f - anum*100 - bnum*100) // c + 1
        water = anum*a*100 + bnum*b*100
        if anum == 0 and bnum == 0:
            break
        for cnum in range(max_cnum):
            max_dnum = (f - anum*100 - bnum*100 - cnum*c) // d + 1
            for dnum in range(max_dnum):
                suger = cnum*c + dnum*d
                nodo = (suger*100) / (water + suger)
                if nodo > (e*100)/(100+e) or water + suger > f:
                    break
                if max_nodo < nodo:
                    max_nodo = nodo
                    res[0] = water + suger
                    res[1] = suger
print(str(res[0]) + " " + str(res[1]))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
res = [0, 0]
max_nodo = 0
max_anum = f // (a*100)+1
for anum in range(max_anum):
    max_bnum = (f - anum*100) // (b*100) + 1
    for bnum in range(max_bnum):
        max_cnum = (f - anum*100 - bnum*100) // c + 1
        water = anum*a*100 + bnum*b*100
        if anum == 0 and bnum == 0:
            break
        for cnum in range(max_cnum):
            max_dnum = (f - anum*100 - bnum*100 - cnum*c) // d + 1
            for dnum in range(max_dnum):
                suger = cnum*c + dnum*d
                nodo = (suger*100) / (water + suger)
                if nodo > (e*100)/(100+e) or water + suger > f:
                    break
                if max_nodo < nodo:
                    print(anum, bnum, cnum, dnum)
                    print(nodo, e, water, suger, f)
                    max_nodo = nodo
                    res[0] = water + suger
                    res[1] = suger
print(str(res[0]) + " " + str(res[1]))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = list(map(int, input().split()))
res = [0, 0]
max_nodo = 0
max_anum = f // (a*100) + 1
max_bnum = f // (b*100) + 1
for anum in range(max_anum):
    for bnum in range(1, max_bnum):
        max_cnum = (f - (anum*100) - (bnum * 100)) // c + 1
        max_dnum = (f - (anum*100) - (bnum * 100)) // d + 1
        for cnum in range(max_cnum):
            for dnum in range(max_dnum):
                water = (anum + bnum) *100
                suger = cnum*c + dnum*d
                nodo = suger / (water + suger) * 100
                if nodo > e or water + suger > f:
                    break
                if max_nodo < nodo:
                    max_nodo = nodo
                    res[0] = water + suger
                    res[1] = suger
print(str(res[0]) + " " + str(res[1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))

water = {}
for i in range(A[5]//(100*A[0])+1):
    for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
        water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)

ans = [100*min(A[0],A[1]), 0]
max_ = -1

for w in water.keys():
    for c in range(min((w//100*A[4])//A[2]+1,(A[5]-w)//A[2]+1)):
        d = min(((w//100*A[4])-c*A[2])//A[3], (A[5]-w-c*A[2])//A[3])
        tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
        if max_ < tmp and (w+A[2]*c+A[3]*d) < A[5]:
            ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
            max_=tmp

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))

water = {}
for i in range(A[5]//(100*A[0])+1):
    for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
        water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)

ans = [100*min(A[0],A[1]), 0]
max_ = 0

for w in water.keys():
    for c in range(min((w//100*A[4])//A[2]+1,(A[5]-w)//A[2]+1)):
        d = min(((w//100*A[4])-c*A[2])//A[3], (A[5]-w-c*A[2])//A[3])
        tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
        if max_ < tmp and (w+A[2]*c+A[3]*d) < A[5]:
            ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
            max_=tmp

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))

water = {}
for i in range(A[5]//(100*A[0])+1):
    for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
        water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)

ans = [0, 0]
max_ = 0

for w in water.keys():
    for c in range(min((w//100*A[4])//A[2]+1,(A[5]-w)//A[2]+1)):
        d = min(((w//100*A[4])-c*A[2])//A[3], (A[5]-w-c*A[2])//A[3])
        tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
        if max_ < tmp and (w+A[2]*c+A[3]*d) < A[5]:
            ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
            max_=tmp

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))

water = {}
for i in range(A[5]//(100*A[0])+1):
    for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
        water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)

ans = [0, 0]
max_ = 0

for w in water.keys():
    for c in range((w//100*A[4])//A[2]+1):
        d = ((w//100*A[4])-c*A[2])//A[3]
        d = min(d,(A[5]-w-c*A[2])//A[3])
        tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
        if max_ < tmp and (w+A[2]*c+A[3]*d) < A[5]:
            ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
            max_=tmp

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))

water = {}
for i in range(A[5]//(100*A[0])+1):
    for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
        water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)

ans = [0, 0]
max_ = 0

for w in water.keys():
    for c in range((w//100*A[4])//A[2]+1):
        d = ((w//100*A[4])-c*A[2])//A[3]
        tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
        if max_ < tmp and (w+A[2]*c+A[3]*d) < A[5]:
            ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
            max_=tmp

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

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))

water = {}
for i in range(A[5]//(100*A[0])+1):
    for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
        water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)
print(water)
ans = [0, 0]
max_ = 0

for w in water.keys():
    for c in range((w//100*A[4])//A[2]+1):
        d = ((w//100*A[4])-c*A[2])//A[3]
        tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
        if max_ < tmp and (w+A[2]*c+A[3]*d) < A[5]:
            ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
            max_=tmp

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
ans_x = 100
ans_y = 0
m = 0
for i in range(int(f/(100*a))+1):
    for j in range(int((f-100*a*i)/(100*b))+1):
        if i+j == 0:
            continue
        x = (a*i + b*j) * 100
        for k in range(int((f-x)/c)+1):
            for l in range(int((f-x-c*k)/d)+1):
                y = c*k + d*l
                if x+y <= f:
                    if (100*y)/(x+y) <= (100*e)/(100+e):
                        if (100*y)/(x+y) > m:
                            ans_x = x
                            ans_y = y
                            m = (100*y)/(x+y)
print(ans_x+ans_y,ans_y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
ans_x = 0
ans_y = 0
m = 0
for i in range(int(f/(100*a))+1):
    for j in range(int((f-100*a*i)/(100*b))+1):
        if i+j == 0:
            continue
        x = (a*i + b*j) * 100
        for k in range(int((f-x)/c)+1):
            for l in range(int((f-x-c*k)/d)+1):
                y = c*k + d*l
                if x+y <= f:
                    if (100*y)/(x+y) <= (100*e)/(100+e):
                        if (100*y)/(x+y) > m:
                            ans_x = x
                            ans_y = y
                            m = (100*y)/(x+y)
print(ans_x+ans_y,ans_y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
ans_x = 0
ans_y = 0
m = 0
for i in range(int(f/(100*a))):
    for j in range(int((f-100*a*i)/(100*b))):
        if i+j == 0:
            continue
        x = (a*i + b*j) * 100
        for k in range(int((f-x)/c)):
            for l in range(int((f-x-c*k)/d)):
                y = c*k + d*l
                if x+y <= f:
                    if (100*y)/(x+y) <= (100*e)/(100+e):
                        if (100*y)/(x+y) > m:
                            ans_x = x
                            ans_y = y
                            m = (100*y)/(x+y)
print(ans_x+ans_y,ans_y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
ans_x = 0
ans_y = 0
ans_p = 0
for i in range(f):
    for j in range(f):
        x = 100 * a * i + 100 * b * j
        y = c * i + d * j
        if x + y <= f and y <= (x/100) * e:
            if x+y == 0:
                continue
            elif (100*y)/(x+y) >= ans_p:
                ans_x = x
                ans_y = y
                ans_p = (100*y)/(x+y)
print(ans_x+ans_y,ans_y)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
n = f / (100 + e)
m = 0
s = 0
if a <= n:
    m = a
if c <= n:
    s = c
print(100*m+s,s)

Submission status: Wrong Answer

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

water = {}
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        wtr = 100*a*i+100*b*j
        if wtr <= f and not wtr in water.keys():
            water[wtr] = 1
water = sorted(water.keys())[1:]

suger = {}
for i in range(f//c+1):
    for j in range(f//d+1):
        sgr = c*i+d*j
        if sgr <= f and not sgr in suger.keys():
            suger[sgr] = 1
suger = sorted(suger.keys())
# print(water, suger)

ans_w = 0
ans_s = 0
concent = 0
for wtr in water:
    for sgr in suger:
        if wtr+sgr > f:
            break
        if sgr > (wtr//100)*e:
            break
        if sgr/(sgr+wtr) > concent:
            concent = sgr/(sgr+wtr)
            ans_w = wtr+sgr
            ans_s = sgr

print(ans_w, ans_s)

Submission status: Wrong Answer

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

water = {}
for i in range(1, f//(100*a)+1):
    for j in range(0, f//(100*b)+1):
        wtr = 100*a*i+100*b*j
        if wtr <= f and not wtr in water.keys():
            water[wtr] = 1
water = sorted(water.keys())

suger = {}
for i in range(f//c+1):
    for j in range(f//d+1):
        sgr = c*i+d*j
        if sgr <= f and not sgr in suger.keys():
            suger[sgr] = 1
suger = sorted(suger.keys())
# print(water, suger)

ans_w = 0
ans_s = 0
concent = 0
for wtr in water:
    for sgr in suger:
        if wtr+sgr > f:
            break
        if sgr > (wtr//100)*e:
            break
        if sgr/(sgr+wtr) > concent:
            concent = sgr/(sgr+wtr)
            ans_w = wtr+sgr
            ans_s = sgr

print(ans_w, ans_s)

Submission status: Wrong Answer

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

water = {}
for i in range(1, f//(100*a)+1):
    for j in range(0, f//(100*b)+1):
        wtr = 100*a*i+100*b*j
        if wtr <= f and not wtr in water.keys():
            water[wtr] = 1
water = sorted(water.keys())

suger = {}
for i in range(f+1):
    for j in range(f-i+1):
        sgr = c*i+d*j
        if sgr <= f and not sgr in suger.keys():
            suger[sgr] = 1
suger = sorted(suger.keys())
# print(water, suger)

ans_w = 0
ans_s = 0
concent = 0
for wtr in water:
    for sgr in suger:
        if wtr+sgr > f:
            break
        if sgr > (wtr//100)*e:
            break
        if sgr/(sgr+wtr) > concent:
            concent = sgr/(sgr+wtr)
            ans_w = wtr+sgr
            ans_s = sgr

print(ans_w, ans_s)

Submission status: Wrong Answer

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

water = {}
for i in range(1, f//(100*a)+1):
    for j in range(0, f//(100*b)+1):
        wtr = 100*a*i+100*b*j
        if wtr <= f and not wtr in water.keys():
            water[wtr] = 1
water = sorted(water.keys())

suger = {}
for i in range(f+1):
    for j in range(f-i+1):
        sgr = c*i+d*j
        if sgr <= f and not sgr in suger.keys():
            suger[sgr] = 1
suger = sorted(suger.keys())
print(water, suger)

ans_w = 0
ans_s = 0
concent = 0
for wtr in water:
    for sgr in suger:
        if wtr+sgr > f:
            break
        if sgr > (wtr//100)*e:
            break
        if sgr/(sgr+wtr) > concent:
            concent = sgr/(sgr+wtr)
            ans_w = wtr+sgr
            ans_s = sgr

print(ans_w, ans_s)

Submission status: Wrong Answer

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

water = {}
for wa in range(100*a, f+1, 100*a):
    for wb in range(0, f+1, 100*b):
        wab = wa+wb
        if wab <= f and not wab in water.keys():
            water[wab] = 1
water = sorted(water.keys())

suger = {}
for sc in range(c, f+1, c):
    for sd in range(0, f+1, d):
        scd = sc+sd
        if scd <= f and not scd in suger.keys():
            suger[scd] = 1
suger = sorted(suger.keys())
# print(water, suger)

ans_w = 0
ans_s = 0
concent = 0
for wtr in water:
    for sgr in suger:
        if wtr+sgr > f:
            break
        if sgr > (wtr//100)*e:
            break
        if sgr/(sgr+wtr) > concent:
            concent = sgr/(sgr+wtr)
            ans_w = wtr+sgr
            ans_s = sgr

print(ans_w, ans_s)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    best = 0
    ans = (0, 0)
    for a in range(F // (100 * A) + 1):
        for b in range(F // (100 * B) + 1):
            if a == 0 and b == 0:
                continue
            for c in range(F // C + 1):
                w = 100 * (a * A + b * B)
                d = min((F - w - c * C), E * w // 100 - c * C) // D
                if d < 0:
                    continue
                s = c * C + d * D
                if best < ((100 * s) / (w + s)):
                    best = (100 * s) / (w + s)
                    ans = (w + s, s)

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

a *= 100
b *= 100

# 得る水の量をすべて列挙する
wt_amt_set = set()
max_a = int(f // a)
max_b = int(f // b)

for a_num in range(max_a + 1):
    for b_num in range(max_b + 1):
        wt_amt = a * a_num + b * b_num
        if 0 < wt_amt <= f:
            wt_amt_set.add(wt_amt)

# wt_amt_set = set()
# max_b = f // (100 * b)
#
# for i in range(max_b + 1):
#     wt_amt = i * b * 100
#     if wt_amt >= f:
#         break
#
#     if wt_amt != 0:
#         wt_amt_set.add(wt_amt)
#
#     while True:
#         wt_amt += a * 100
#         if wt_amt >= f:
#             break
#
#         wt_amt_set.add(wt_amt)

# 取りうる砂糖の量
sg_amt_set = set()
max_sugar = f / 100 * e
max_d = int(max_sugar // d)
max_c = int(max_sugar // c)

for d_num in range(max_d + 1):
    for c_num in range(max_c + 1):
        sg_amt = d * d_num + c * c_num
        if 0 < sg_amt <= max_sugar:
            sg_amt_set.add(sg_amt)

# 全探索
best_conc = 0
best_weight = 0
best_sugar = 0

# print(sorted(wt_amt_set))
# print(sorted(sg_amt_set))

for wt_amt in sorted(wt_amt_set):
    for sg_cd in list(sg_amt_set):
        weight = wt_amt + sg_cd
        conc = sg_cd / (sg_cd + wt_amt)
        sugar = sg_cd

        if (weight > f) or (sugar > e * wt_amt / 100):
            continue

        if conc > best_conc:
            best_conc = conc
            best_weight = weight
            best_sugar = sugar

print(best_weight, best_sugar)

Submission status: Wrong Answer

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

# 得る水の量をすべて列挙する
wt_amt_set = set()
max_b = f // (100 * b)

for i in range(max_b + 1):
    wt_amt = i * b * 100
    if wt_amt >= f:
        break

    if wt_amt != 0:
        wt_amt_set.add(wt_amt)

    while True:
        wt_amt += a * 100
        if wt_amt >= f:
            break

        wt_amt_set.add(wt_amt)


# 取りうる砂糖の量
sg_amt_set = set()
max_sugar = f / 100 * e
max_d = int(max_sugar // d)
max_c = int(max_sugar // c)

for d_num in range(max_d+1):
    for c_num in range(max_c+1):
        sg_amt = d * d_num + c * c_num
        if sg_amt == 0:
            continue
        if sg_amt <= max_sugar:
            if sg_amt != 0:
                sg_amt_set.add(sg_amt)

# 全探索
best_conc = 0
best_weight = 0
best_sugar = 0

for wt_amt in sorted(wt_amt_set):
    for sg_cd in list(sg_amt_set):
        weight = wt_amt + sg_cd
        conc = sg_cd / (sg_cd + wt_amt)
        sugar = sg_cd

        if (weight > f) or (sugar > e * wt_amt / 100):
            continue

        if conc > best_conc:
            best_conc = conc
            best_weight = weight
            best_sugar = sugar

print(best_weight, best_sugar)

Submission status: Wrong Answer

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

# 得る水の量をすべて列挙する
wt_amt_set = set()
max_b = f // (100 * b)

for i in range(max_b + 1):
    wt_amt = i * b * 100
    if wt_amt >= f:
        break

    if wt_amt != 0:
        wt_amt_set.add(wt_amt)

    while True:
        wt_amt += a * 100
        if wt_amt >= f:
            break

        wt_amt_set.add(wt_amt)


# 取りうる砂糖の量
sg_amt_set = set()
max_sugar = f / 100 * e
max_d = int(max_sugar // d)
max_c = int(max_sugar // c)

for d_num in range(max_d+1):
    for c_num in range(max_c+1):
        sg_amt = d * d_num + c * c_num
        if sg_amt == 0:
            continue
        if sg_amt <= max_sugar:
            sg_amt_set.add(sg_amt)

# 全探索
best_conc = 0
best_weight = 0
best_sugar = 0

for wt_amt in sorted(wt_amt_set):
    for sg_cd in list(sg_amt_set):
        weight = wt_amt + sg_cd
        conc = sg_cd / (sg_cd + wt_amt)
        sugar = sg_cd

        if (weight > f) or (sugar > e * wt_amt / 100):
            continue

        if conc > best_conc:
            best_conc = conc
            best_weight = weight
            best_sugar = sugar

print(best_weight, best_sugar)

Submission status: Wrong Answer

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

# まず、とり得る水の量をすべて列挙する
wt_amt_set = set()
max_b = f // (100 * b)

for i in range(max_b + 1):
    wt_amt = i * b * 100
    if wt_amt >= f:
        break

    if wt_amt != 0:
        wt_amt_set.add(wt_amt)

    while True:
        wt_amt += a * 100
        if wt_amt >= f:
            break

        wt_amt_set.add(wt_amt)

# 取りうる砂糖の量
sg_amt_set = set()
max_sugar = f / 100 * e
max_d = int(max_sugar // d)
max_c = int(max_sugar // c)

for d_num in range(d+1):
    for c_num in range(c+1):
        sg_amt = d * d_num + c * c_num
        if sg_amt <= max_sugar:
            sg_amt_set.add(sg_amt)

best_conc = 0
best_weight = 0
best_sugar = 0

for wt_amt in sorted(wt_amt_set):
    for sg_cd in list(sg_amt_set):
        weight = wt_amt + sg_cd
        conc = sg_cd / (sg_cd + wt_amt)
        sugar = sg_cd

        if (weight > f) or (sugar > e * wt_amt / 100):
            continue

        if conc > best_conc:
            best_conc = conc
            best_weight = weight
            best_sugar = sugar

print(best_weight, best_sugar)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F=map(int, input().split())
a=[[str(100*A),'0']]
for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(101):
                x=100*A*i+100*B*j
                y=C*k+D*l
                if x+y>F or x==0 or y==0:
                    break
                if 100*y/(x+y)<=(E*100)/(100+E):
                    a.append([str(x+y),str(y)])
print(' '.join(sorted(a, key=lambda x: (100*int(x[1]))/int(x[0]) if int(x[0])!=0 else 0)[-1]))

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F=map(int, input().split())
a=[['0','0']]
for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(101):
                x=100*A*i+100*B*j
                y=C*k+D*l
                if x+y>F or x==0 or y==0:
                    break
                if 100*y/(x+y)<=(E*100)/(100+E):
                    a.append([str(x+y),str(y)])
print(' '.join(sorted(a, key=lambda x: (100*int(x[1]))/int(x[0]) if int(x[0])!=0 else 0)[-1]))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
smax =int(F*E/(100+E))
wmax =F-smax
temp = []
for a in range(wmax//(A*100)+1):
    for b in range(wmax // (B*100)+1):
        for c in range(smax // (C)+1):
            for d in range(smax // (D)+1):
                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: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = []
i = 0
while True:
    if 100 * A * i > F:
        break
    j = 0
    while True:
        if 100 * A * i + 100 * B * j > F:
            break
        water.append(100 * A * i + 100 * B * j)
        j += 1
    i += 1

suger = []
i = 0
while True:
    if C * i > F:
        break
    j = 0
    while True:
        if C * i + D * j > F * E / (100 + E):
            break
        suger.append(C * i + D * j)
        j += 1
    i += 1
max_p = 0
max_w = 0
suger.sort()
water.sort()
i = 1
while True:
    if i >= len(suger):
        break
    if suger[i] == suger[i - 1]:
        del suger[i]
    else:
        i += 1
i = 1
while True:
    if i >= len(water):
        break
    if water[i] == water[i - 1]:
        del water[i]
    else:
        i += 1
max_s = 0
for i in water:
    for j in suger:
        if i + j == 0:
            0
        elif i + j <= F and max_p < 100 * j / (i + j) and 100 * E / (100 + E) >= 100 * j / (i + j):
            max_w = i + j
            max_p = 100 * j / (i + j)
            max_s = j


print(max_w, max_s)

Submission status: Wrong Answer

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

water = 0
salt = 0
conc = 0

# water 1..29 * 100 all
for i in range(1,30):
  Amax = i // A
  notMakeFlag = True
  for k in range(Amax + 1):
    if (i - A * k) % B == 0:
      notMakeFlag = False
      break
  if notMakeFlag:
    continue
  
  #print(i)
  # maximize salt within F and E
  
  Cmax = min(E*i, (F-i*100))//C
  saltmax = 0
  for k in range(Cmax + 1):
    Dcount = (min(E*i, (F-i*100)) - k * C) // D
    saltmax = max(saltmax, k*C + Dcount * D)
  
    if conc < saltmax / (saltmax + i * 100):
      water = i * 100
      salt = saltmax
      conc = saltmax / (saltmax + i * 100)

print(water+salt, salt)

Submission status: Wrong Answer

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

water = 0
salt = 0
conc = 0

# water 1..29 * 100 all
for i in range(1,30):
  Amax = i // A
  notMakeFlag = True
  for k in range(Amax + 1):
    if (i - A * k) % B == 0:
      notMakeFlag = False
      break
  if notMakeFlag:
    continue
  
  #print(i)
  # maximize salt within F and E
  
  Cmax = min(E*i, (F-i*100))//C
  saltmax = 0
  for k in range(Cmax + 1):
    Dcount = (min(E*i, (F-i*100)) - k * C) // D
    saltmax = max(saltmax, k*C + Dcount * D)
  
  if conc < saltmax / (saltmax + i * 100):
    water = i * 100
    salt = saltmax
    conc = saltmax / (saltmax + i * 100)

print(water+salt, salt)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = list(map(int, input().split()))
num_A = int(F / A / 100) + 1
num_B = int(F / B / 100) + 1
def opt_s(x, y, S):
    num_x = int(S / x) + 1
    num_y = int(S / y) + 1
    count = 0
    for p in range(num_x):
        for q in range(num_y):
            if x * p + y * q > S:
                break
            else:
                count = max(count, x * p + y * q)
    return count
sugar = 0
water = 0
for i in range(num_A):
    for j in range(num_B):
        if i * A * 100 + j * B * 100 > F:
            break
        else:
            S_max = min(F - i * A * 100 - j * B * 100, E * (i * A + j * B))
            result = opt_s(C, D, S_max)
            if  result > sugar:
                sugar = result
                water = (i * A + j * B) * 100 + sugar
print(water, sugar)