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 = map(int, input().split())

# 可能な水の総量
water_list = []
A_max = F // (100 * A)
B_max = F // (100 * B)
for i in range(A_max + 1):
    for j in range(B_max + 1):
        temp = 100 * A * i + 100 * B * j
        if temp <= F:
            water_list.append(temp)
# 重複は除いておく
water_list = list(set(water_list))

# 可能な砂糖の総量
sugar_list = []
C_max = F // (C)
D_max = F // (D)
for i in range(C_max + 1):
    for j in range(D_max + 1):
        temp = C * i + D * j
        if temp <= F:
            sugar_list.append(temp)
# 重複は除いておく
sugar_list = list(set(sugar_list))

# print(water_list)
# print(sugar_list)

max_conc = 0
max_conc_water = 0
max_conc_sugar = 0
for water in water_list:
    for sugar in sugar_list:
        # 水があるか？　and 溶解度を超えていないか？ and 容器に入るか？
        if water != 0 and sugar < ((E * water) / 100) and water + sugar <= F:
            conc = (100 * sugar) / (water + sugar)
            if conc > max_conc:
                max_conc = conc
                max_conc_water = water
                max_conc_sugar = sugar

print(max_conc_water + max_conc_sugar, max_conc_sugar)
#print(max_conc)

Submission status: Wrong Answer

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

#操作1-4
ope1 = 100 * A
ope2 = 100 * B
ope3 = C
ope = D

#入れた水、砂糖の総量
w_sum = 0
s_sum = 0
#パーセンテージ
p = 0
#トータル
total = 0
#砂糖の表示用の変数
s = 0


for i in range(31):
    b_sum = 100 * B * i
    for ii in range(31):
        a_sum = 100 * A * ii
        for j in range(31):
            d_sum = D * j
            for jj in range(31):
                c_sum = C * jj
                if d_sum + c_sum > (E*i) + (E*ii):
                    c_sum -= C
                if d_sum+c_sum == 0:
                    tmp = 0
                else:    
                    tmp = ((d_sum + c_sum) / (d_sum + c_sum + b_sum + a_sum)) * 100
                if p < tmp and F >= d_sum + c_sum + b_sum + a_sum and b_sum + a_sum != 0 and d_sum + c_sum <= (E*i) + (E*ii):
                    p = tmp
                    total = d_sum + c_sum + b_sum + a_sum
                    s = d_sum + c_sum
                
            
print(total, s)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
import itertools

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

qA = [i // 100 for i in range(0, F + 1, A * 100)]
qB = [i // 100 for i in range(0, F + 1, B * 100)]
qC = [i for i in range(0, F + 1, C)]
qD = [i for i in range(0, F + 1, D)]

W = set(qA + qB)
for i in range(F // min(A, B)):
    nW = deepcopy(W)
    for w in W:
        if (w + A) * 100 <= F:
            nW.add(w + A)
        if (w + B) * 100 <= F:
            nW.add(w + B)

    if len(W) == len(nW):
        break
    W = deepcopy(nW)

W = nW

S = set(qC + qD)
for i in range(F // min(C, D)):
    nS = deepcopy(S)
    for s in S:
        if (s + C) <= F:
            nS.add(s + C)
        if (s + D) <= F:
            nS.add(s + D)

    if len(S) == len(nS):
        break
    S = deepcopy(nS)
S = nS

M = 0
Ms = 0
Mw = 0
for w, s in itertools.product(W, S):
    if w != 0 and s <= w * E and s + 100 * w <= F:
        if M < s / (w * 100 + s):
            M = s / (w * 100 + s)
            Ms = s
            Mw = w

print(Ms + Mw * 100)
print(Ms)

Submission status: Wrong Answer

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

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=set()
for i in range(0,f+1,100*a):
    for j in range(0,f+1,100*b):
        if i+j<=f:
            w.add(i+j)
        else:
            break
s=set()
for i in range(0,f+1,c):
    for j in range(0,f+1,d):
        if i+j<=f:
            s.add(i+j)
        else:
            break
n=0
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: Wrong Answer

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

noudo = 0
satou = 0
sato_mizu = 0

for x in range(F//(100*A)+1):
    for y in range(F//(100*B)+1):
        if 100 * (A*x+B*y) > F:
            break

        for z in range(F // C + 1):
            if C * z > (A * x + B * y) * E:
                break

            if 100 * (A * x + B * y) + C * z > F:
                break

            for w in range(F // C + 1):
                if (C*z + D*w + 100 * (A*x+B*y)) == 0:
                    break

                if C*z + D*w > (A * x + B * y)*E:
                    break

                if 100 * (A*x+B*y)+C*z + D*w > F:
                    break

                # print(x, y, w, z, 100* (C*z + D*w)/(C*z + D*w + 100 * (A*x+B*y)))

                if noudo < 100* (C*z + D*w)/(C*z + D*w + 100 * (A*x+B*y)):
                    noudo = 100* (C*z + D*w)/(C*z + D*w + 100 * (A*x+B*y))
                    sato_mizu = (C*z + D*w + 100 * (A*x+B*y))
                    satou = C*z + D*w
print(sato_mizu, satou)

Submission status: Wrong Answer

Solution code:
import sys

A, B, C, D, E, F = map(int, sys.stdin.readline().split())

max_a = (F - 1) // (100 * A) + 1
max_b = (F - 1) // (100 * B) + 1

max_rate = 0
ans_water = 0
ans_sugar = 0
for a in range(max_a + 1):
    for b in range(max_b + 1):
        water = 100 * A * a + 100 * B * b
        if water >= F:
            break

        max_sugar = min(F - water, water // 100 * E)
        # print("max_sugar", max_sugar)
        max_c = (max_sugar - 1) // C + 1
        max_d = (max_sugar - 1) // D + 1
        for c in range(max_c + 1):
            for d in range(max_d + 1):
                sugar = C * c + D * d
                if sugar > max_sugar or sugar + water > F:
                    break

                if 100 * sugar > max_rate * (water + sugar):
                    max_rate = 100 * sugar / (water + sugar)
                    ans_water = water
                    ans_sugar = sugar

print(ans_water + ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys

A, B, C, D, E, F = map(int, sys.stdin.readline().split())

max_a = (F - 1) // (100 * A) + 1
max_b = (F - 1) // (100 * B) + 1

max_sugar = 30 * E

max_rate = 0
ans_water = 0
ans_sugar = 0
for a in range(max_a + 1):
    for b in range(max_b + 1):
        water = 100 * A * a + 100 * B * b
        if water >= F:
            break

        max_sugar = min(F - water, int(water / 100 * E))
        # print("max_sugar", max_sugar)
        max_c = (max_sugar - 1) // C + 1
        max_d = (max_sugar - 1) // D + 1
        for c in range(max_c + 1):
            for d in range(max_d + 1):
                sugar = C * c + D * d
                if sugar > max_sugar or sugar + water > F:
                    break

                if 100 * sugar > max_rate * (water + sugar):
                    max_rate = 100 * sugar / (water + sugar)
                    ans_water = water
                    ans_sugar = sugar

print(ans_water + ans_sugar, ans_sugar)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
water = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1,100*B):
        if i + j <= F:
            water.add(i + j)
water = list(water)
water.sort()
sugar = set()
for i in range(0,F+1,C):
    for j in range(0,F+1,D):
        if i + j <= F:
            sugar.add(i + j)
sugar = list(sugar)
sugar.sort()
#print(water)
#print(sugar)
ans = [[0,0,0]]
for i in water:
    for j in sugar:
        if i == 0 or j == 0:
            continue
        if i + j <= F and (i//100)*E >= j:
            #print(i,j)
            ans.append([(100*j)/(i+j),i+j,j])
ans.sort()
#print(ans)
print(ans[-1][1],ans[-1][2])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
water = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1,100*B):
        if i + j <= F:
            water.add(i + j)
water = list(water)
water.sort()
sugar = set()
for i in range(0,F+1,C):
    for j in range(0,F+1,D):
        if i + j <= F:
            sugar.add(i + j)
sugar = list(sugar)
sugar.sort()
#print(water)
#print(sugar)
ans = [0,0,0]
for i in water:
    for j in sugar:
        if i == 0 or j == 0:
            continue
        if i + j <= F and E * (i // 100) >= j:
            if (100*j)/(i+j) > ans[0]:
                ans = [(100*j)/(i+j),i+j,j]
print(ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
water = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1,100*B):
        if i + j <= F:
            water.add(i + j)
water = list(water)
water.sort()
sugar = set()
for i in range(0,F+1,C):
    for j in range(0,F+1,D):
        if i + j <= F:
            sugar.add(i + j)
sugar = list(sugar)
sugar.sort()
print(water)
print(sugar)
ans = [0,0,0]
for i in water:
    for j in sugar:
        if i == 0 or j == 0:
            continue
        if i + j <= F and E * (i // 100) >= j:
            if (100*j)/(i+j) > ans[0]:
                ans = [(100*j)/(i+j),i+j,j]
print(ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
water = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1,100*B):
        if i + j <= F:
            water.add(i + j)
water = list(water)
water.sort()
sugar = set()
for i in range(0,F+1,C):
    for j in range(0,F+1,D):
        if i + j <= F:
            sugar.add(i + j)
sugar = list(sugar)
sugar.sort()
#print(water)
#print(sugar)
ans = [0,0,0]
for i in water:
    for j in sugar:
        if i == 0 and j == 0:
            continue
        if i + j <= F and E * (i // 100) >= j:
            if (100*j)/(i+j) > ans[0]:
                ans = [(100*j)/(i+j),i+j,j]
print(ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

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

water = set()
sugar = [0]*(F+1)

for a in range(F//(100*A)+1):
	for b in range((F-100*a*A)//(100*B)+1):
		water.add(100*(a*A+b*B))

f = F//2
for c in range(f//C+1):
	for d in range((f-c*C)//D+1):
		sugar[c*C+d*D] = 1

sugar_acc = [0]*(F+1)
tmp = 0
for i in range(F//2+1):
	if sugar[i] == 1:
		tmp = i
	sugar_acc[i] = tmp

#print(water)
#print(sugar_acc)

ans = 0
den = 0
water_ans = 0
sugar_ans = 0

for water_tmp in water:
	if E == 100:
		t = min(water_tmp, F-water_tmp)
	else:
		t = min(E*water_tmp//100, F-water_tmp)

	sugar_tmp = sugar_acc[t]
	if F < sugar_tmp + water_tmp:
		continue

	if sugar_tmp == 0:
		den_tmp = 0
	else:
		den_tmp = sugar_tmp/(sugar_tmp+water_tmp)

	#print(water_tmp, sugar_tmp, den_tmp, E*water_tmp//(100-E), F-water_tmp, t)
	if den < den_tmp:
		den = den_tmp
		water_ans = water_tmp
		sugar_ans = sugar_tmp

print(water_ans+sugar_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

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

water = set()
sugar = [0]*(F+1)

for a in range(F//(100*A)+1):
	for b in range((F-100*a*A)//(100*B)+1):
		water.add(100*(a*A+b*B))

f = F//2
for c in range(f//C+1):
	for d in range((f-c*C)//D+1):
		sugar[c*C+d*D] = 1

sugar_acc = [0]*(F+1)
tmp = 0
for i in range(F//2+1):
	if sugar[i] == 1:
		tmp = i
	sugar_acc[i] = tmp

#print(water)
#print(sugar_acc)

ans = 0
den = 0
water_ans = 0
sugar_ans = 0

for water_tmp in water:
	if E == 100:
		t = min(water_tmp, F-water_tmp)
	else:
		t = min(E*water_tmp//(100-E), F-water_tmp)

	sugar_tmp = sugar_acc[t]
	if F < sugar_tmp + water_tmp:
		continue

	if sugar_tmp == 0:
		den_tmp = 0
	else:
		den_tmp = sugar_tmp/(sugar_tmp+water_tmp)

	#print(water_tmp, sugar_tmp, den_tmp, E*water_tmp//(100-E), F-water_tmp, t)
	if den < den_tmp:
		den = den_tmp
		water_ans = water_tmp
		sugar_ans = sugar_tmp

print(water_ans+sugar_ans, sugar_ans)

Submission status: Wrong Answer

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

for i in range(3001):
    for j in range(3001):
        v = 100*A*i+100*B*j
        if v <= F:
            a.append(v)
        else:
            break

for i in range(3001):
    for j in range(3001):
        v = C*i+D*j
        if v <= F:
            b.append(v)
        else:
            break

a.sort()
b.sort()

c = 0
ans = [0, 0]
for ai in a:
    for bi in b:
        t = ai+bi
        if t > 0 and t <= F and (E*ai//100) >= bi:
            tc = 100*bi/(ai+bi)
            if c < tc:
                c = tc
                ans = [t, bi]

print(*ans)

Submission status: Wrong Answer

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

for i in range(31):
    for j in range(31):
        v = 100*A*i+100*B*j
        if v < F:
            a.append(v)
        else:
            break

for i in range(3000//C+2):
    for j in range(3000//D+2):
        v = C*i+D*j
        if v < F:
            b.append(v)
        else:
            break

c = 0
ans = [0, 0]
for ai in a:
    for bi in b:
        t = ai+bi
        if t > 0 and t <= F and (E*ai//100) >= bi:
            tc = 100*bi/(ai+bi)
            if c < tc:
                c = tc
                ans = [t, bi]
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

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

density = 0
ans = (0,0)
for i in range(30):  # 操作1の行う回数
    for j in range(30):  # 操作2の行う回数
        if i == 0 and j == 0:
            continue
        elif 100*(A*i+B*j) >= F:
            continue
        else:
            r = min(F-100*(A*i+B*j),E*(A*i+B*j))  # 溶かせる砂糖の上限
            a = r
            for k in range(C):
                s = r-D*k
                if s < 0:
                    break
                else:
                    a = min(a,s % C)
            if density < (r-a)/((r-a)+100*(A*i+B*j)):
                density = (r-a)/((r-a)+100*(A*i+B*j))
                ans = ((r-a)+100*(A*i+B*j),(r-a))

print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    # 濃度0%のケース
    if e == 0 or min(a, b) == f:
        print(a, 0)
        sys.exit()
    water = [0] * 6001
    water[0] = True
    for i1 in range(3001):
        if water[i1]:
            water[i1 + a] = True
            water[i1 + b] = True
    sugar = [0] * 6001
    sugar[0] = True
    for i1 in range(3001):
        if sugar[i1]:
            sugar[i1 + c] = True
            sugar[i1 + d] = True

    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if water[i1]:
            for i2 in range(f + 1):
                if i1 + i2 > f:
                    break
                if sugar[i2]:
                    if i1 * e >= i2 * 100:
                        if noudo < i2 / (i1 + i2):
                            noudo = i2 / (i1 + i2)
                            r1 = int(i1 + i2)
                            r2 = int(i2)
                    else:
                        break
    print(r1, r2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100
    if e == 0:
        print(a, 0)
        sys.exit()
    elif min(a, b) == f:
        print(a, 0)
        sys.exit()

    anum = [i for i in range(1, 3001) if i % a == 0]
    bnum = [i for i in range(1, 3001) if i % b == 0]
    ab = anum + bnum
    ab.sort(reverse=True)
    water = [i % a == 0 or i % b == 0 for i in range(3001)]
    if not all(water):
        for abe in ab:
            for i1 in range(3001 - abe):
                if water[i1]:
                    water[i1 + abe] = True
    smax = ceil(3000 / 100 * e + 1)
    cnum = [i for i in range(1, smax) if i % c == 0]
    dnum = [i for i in range(1, smax) if i % d == 0]
    cd = cnum + dnum
    cd.sort(reverse=True)
    sugar = [i % c == 0 or i % d == 0 for i in range(smax)]
    if not all(sugar):
        for cde in cd:
            for i1 in range(smax - cde):
                if sugar[i1]:
                    sugar[i1 + cde] = True
    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if not water[i1]:
            continue
        for i2 in range(smax):
            if i1 + i2 > f:
                break
            if sugar[i2]:
                if i1 / 100 * e >= i2:
                    if noudo < (100 * i2) / (i1 + i2):
                        noudo = (100 * i2) / (i1 + i2)
                        r1 = int(i1 + i2)
                        r2 = int(i2)
                else:
                    break
    print(r1, r2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100
    if e == 0:
        print(a, 0)
        sys.exit()
    anum = [i for i in range(1, 3001) if i % a == 0]
    bnum = [i for i in range(1, 3001) if i % b == 0]
    ab = anum + bnum
    ab.sort(reverse=True)
    water = [i % a == 0 or i % b == 0 for i in range(3001)]
    if not all(water):
        for abe in ab:
            for i1 in range(3001 - abe):
                if water[i1]:
                    water[i1 + abe] = True
    smax = ceil(3000 / 100 * e + 1)
    cnum = [i for i in range(1, smax) if i % c == 0]
    dnum = [i for i in range(1, smax) if i % d == 0]
    cd = cnum + dnum
    cd.sort(reverse=True)
    sugar = [i % c == 0 or i % d == 0 for i in range(smax)]
    if not all(sugar):
        for cde in cd:
            for i1 in range(smax - cde):
                if sugar[i1]:
                    sugar[i1 + cde] = True
    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if not water[i1]:
            continue
        for i2 in range(smax):
            if i1 + i2 > f:
                break
            if sugar[i2]:
                if i1 / 100 * e >= i2:
                    if noudo < (100 * i2) / (i1 + i2):
                        noudo = (100 * i2) / (i1 + i2)
                        r1 = int(i1 + i2)
                        r2 = int(i2)
                else:
                    break
    print(r1, r2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100
    anum = [i for i in range(1, 3001) if i % a == 0]
    bnum = [i for i in range(1, 3001) if i % b == 0]
    ab = anum + bnum
    ab.sort(reverse=True)
    water = [i % a == 0 or i % b == 0 for i in range(3001)]
    if not all(water):
        for abe in ab:
            for i1 in range(3001 - abe):
                if water[i1]:
                    water[i1 + abe] = True
    smax = ceil(3000 / 100 * e + 1)
    cnum = [i for i in range(1, smax) if i % c == 0]
    dnum = [i for i in range(1, smax) if i % d == 0]
    cd = cnum + dnum
    cd.sort(reverse=True)
    sugar = [i % c == 0 or i % d == 0 for i in range(smax)]
    if not all(sugar):
        for cde in cd:
            for i1 in range(smax - cde):
                if sugar[i1]:
                    sugar[i1 + cde] = True
    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if not water[i1]:
            continue
        for i2 in range(smax):
            if i1 + i2 > f:
                break
            if sugar[i2]:
                if i1 / 100 * e >= i2:
                    if noudo < (100 * i2) / (i1 + i2):
                        noudo = (100 * i2) / (i1 + i2)
                        r1 = int(i1 + i2)
                        r2 = int(i2)
                else:
                    break
    print(r1, r2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100
    anum = [i for i in range(1, 3001) if i % a == 0]
    bnum = [i for i in range(1, 3001) if i % b == 0]
    ab = anum + bnum
    ab.sort(reverse=True)
    water = [i % a == 0 or i % b == 0 for i in range(3001)]
    if not all(water):
        for abe in ab:
            for i1 in range(3001 - abe):
                if water[i1]:
                    water[i1 + abe] = True
    smax = 3000 // 100 * e + 1
    cnum = [i for i in range(1, smax) if i % c == 0]
    dnum = [i for i in range(1, smax) if i % d == 0]
    cd = cnum + dnum
    cd.sort(reverse=True)
    sugar = [i % c == 0 or i % d == 0 for i in range(smax)]
    if not all(sugar):
        for cde in cd:
            for i1 in range(smax - cde):
                if sugar[i1]:
                    sugar[i1 + cde] = True
    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if not water[i1]:
            continue
        for i2 in range(smax):
            if i1 + i2 > f:
                break
            if sugar[i2]:
                if i1 / 100 * e >= i2:
                    if noudo < (100 * i2) / (i1 + i2):
                        noudo = (100 * i2) / (i1 + i2)
                        r1 = int(i1 + i2)
                        r2 = int(i2)
                else:
                    break
    print(r1, r2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100
    anum = [i for i in range(1, 3001) if i % a == 0]
    bnum = [i for i in range(1, 3001) if i % b == 0]
    ab = anum + bnum
    ab.sort(reverse=True)
    water = [i % a == 0 or i% b == 0 for i in range(3001)]
    if not all(water):
        for abe in ab:
            for i1 in range(3001 - abe):
                if water[i1]:
                    water[i1 + abe] = True
    smax = 3000 // 100 * e + 1
    cnum = [i for i in range(1, smax) if i % c == 0]
    dnum = [i for i in range(1, smax) if i % d == 0]
    cd = cnum + dnum
    cd.sort(reverse=True)
    sugar = [i % c == 0 or i % d == 0 for i in range(smax)]
    if not all(sugar):
        for cde in cd:
            for i1 in range(smax - cde):
                if sugar[i1]:
                    sugar[i1 + cde] = True
    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if not water[i1]:
            continue
        for i2 in range(smax * f // 3000):
            if i1 + i2 > f:
                break
            if sugar[i2]:
                if i1 / 100 * e >= i2:
                    if noudo < (100 * i2) / (i1 + i2):
                        noudo = (100 * i2) / (i1 + i2)
                        r1 = int(i1 + i2)
                        r2 = int(i2)
                else:
                    break
    print(r1, r2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100
    anum = [i for i in range(1, 3001) if i % a == 0]
    bnum = [i for i in range(1, 3001) if i % b == 0]
    ab = anum + bnum
    ab.sort(reverse=True)
    water = [i % a == 0 or i% b == 0 for i in range(3001)]
    if not all(water):
        for abe in ab:
            for i1 in range(3001 - abe):
                if water[i1]:
                    water[i1 + abe] = True
    smax = 3001 // 100 * e + 1
    cnum = [i for i in range(1, smax) if i % c == 0]
    dnum = [i for i in range(1, smax) if i % d == 0]
    cd = cnum + dnum
    cd.sort(reverse=True)
    sugar = [i % c == 0 or i % d == 0 for i in range(smax)]
    if not all(sugar):
        for cde in cd:
            for i1 in range(smax - cde):
                if sugar[i1]:
                    sugar[i1 + cde] = True
    noudo = 0
    r1 = 0
    r2 = 0
    for i1 in range(1, f + 1):
        if not water[i1]:
            continue
        for i2 in range(smax * f // 3000):
            if i1 + i2 > f:
                break
            if sugar[i2]:
                if i1 / 100 * e >= i2:
                    if noudo < (100 * i2) / (i1 + i2):
                        noudo = (100 * i2) / (i1 + i2)
                        r1 = i1 + i2
                        r2 = i2
                else:
                    break
    print(r1, r2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split(" "))
water = set()
lf = f // min(100 * a, 100 * b)
for i in range(lf + 1):
    for j in range(lf + 1):
        w = 100 * a * i + 100 * b * j
        if f >= w:
            water.add(w)
        else:
            break
water.remove(0)
nodo = 0
total = 0
msuger = 0
for w in water:
    suger = e * w / 100
    ls = (f - w)//min(c, d)
    for i in range(ls + 1):
        for j in range(ls + 1):
            s = c * i + d * j
            if s <= suger and s + w <= f and nodo < s / (w + s):
                nodo = s / (w + s)
                msuger = s
                total = w + s

print(str(total) + " " + str(msuger))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split(" "))
water = set()
lf = f // min(100 * a, 100 * b)
for i in range(lf + 1):
    for j in range(lf + 1):
        w = 100 * a * i + 100 * b * j
        if f >= w:
            water.add(w)
        else:
            break
water.remove(0)
nodo = 0
total = 0
msuger = 0
for w in water:
    suger = e * w / 100
    ls = (f - w)//min(c, d)
    for i in range(ls):
        for j in range(ls):
            s = c * i + d * j
            if s <= suger and s + w <= f and nodo < s / (w + s):
                nodo = s / (w + s)
                msuger = s
                total = w + s

print(str(total) + " " + str(msuger))

Submission status: Wrong Answer

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

x = set()

for i in range(F):
  for j in range(F):
    water = 100 * A * i + 100 * B * j
    if F >=  water:
      x.add(water)
    else:
      break

sugar = water / 100 * E

y = set()

for i in range(F):
  for j in range(F):
    sugar = C * i + D * j
    if F >= sugar:
      y.add(sugar)
    else:
      break

x = list(x) # water
y = list(y) # sugar
percentage = 0
sugarWater = 0
ansSugar = 0

for i in range(len(x)):
  for j in range(len(y)):
    if x[i] + y[j] == 0:
      pass
    elif F >= x[i] + y[j]:
      if y[j] <= E * x[i] / 100:
        p = 100 * y[j] / ( x[i] + y[j] )
        if p > percentage:
          percentage = p
          sugarWater = x[i] + y[j]
          ansSugar = y[j]

print(str(sugarWater) + " " + str(ansSugar))