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())
mx=0
swmx=100*a
smx=0

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,1501):          
            w=100*a*i+100*b*j
            s=c*k
            if e*w/100>=s:
                s+=((e*w/100-s)//d)*d
            else:
                break
            if w+s<=f  and w!=0 and mx<100*s/(w+s):
                mx=100*s/(w+s)
                swmx=w+s
                smx=s
print(int(swmx),int(smx))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
mx=0
swmx=100*a
smx=0

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,1501):          
            w=100*a*i+100*b*j
            s=c*k
            if e*w/100>s:
                s+=((e*w/100-s)//d)*d
            else:
                continue
            if w+s<=f  and w!=0 and mx<100*s/(w+s):
                mx=100*s/(w+s)
                swmx=w+s
                smx=s
print(int(swmx),int(smx))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
mx=0
swmx=100*a
smx=0

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,1501):          
            w=100*a*i+100*b*j
            s=c*k
            if e*(a*i+b*j)>=s:
                s+=((e*w/100-s)//d)*d
            else:
                continue
            if w+s<=f and s<=e*w/100 and w!=0 and mx<100*s/(w+s):
                mx=100*s/(w+s)
                swmx=w+s
                smx=s
print(int(swmx),int(smx))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
mx=0
swmx=100*a
smx=0

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,1501):          
            w=100*a*i+100*b*j
            s=c*k
            if e*w/100>=s:
                s+=((e*w/100-s)//d)*d
            else:
                continue
            if w+s<=f and w!=0 and mx<100*s/(w+s):
                mx=100*s/(w+s)
                swmx=w+s
                smx=s
print(int(swmx),int(smx))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
mx=0
swmx=100*a
smx=0

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,1501):          
            w=100*a*i+100*b*j
            s=c*k
            if e*w/100>=s:
                s+=((e*w/100-s)//d)*d
            else:
                continue
            if w+s<=f and w!=0 and mx<100*s/(w+s):
                mx=100*s/(w+s)
                swmx=w+s
                smx=s
print(int(swmx),int(smx))

Submission status: Wrong Answer

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

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,1501):          
            w=100*a*i+100*b*j
            s=c*k
            if e*w/100>=s:
                s+=((e*w/100-s)//d)*d
            else:
                continue
            if w+s<=f  and w!=0 and mx<100*s/(w+s):
                mx=100*s/(w+s)
                swmx=w+s
                smx=s
print(int(swmx),int(smx))

Submission status: Wrong Answer

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

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,1501):          
            w=0
            s=0
            w+=100*a*i+100*b*j
            s+=c*k
            sm=e*w/100
            if sm>=s:
                s+=((sm-s)//d)*d
            else:
                continue
            if w+s<=f  and w!=0 and mx<100*s/(w+s):
                mx=100*s/(w+s)
                swmx=w+s
                smx=s
print(int(swmx),int(smx))

Submission status: Wrong Answer

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

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,251):
            for l in range(0,251):
                w=0
                s=0
                w+=100*a*i+100*b*j
                s+=c*k+d*l
                if w+s<=f and s<=e*w/100 and w!=0 and mx<100*s/(w+s):
                    mx=100*s/(w+s)
                    swmx=w+s
                    smx=s
print(swmx,smx)

Submission status: Wrong Answer

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

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,151):
            for l in range(0,151):
                w=0
                s=0
                w+=100*a*i+100*b*j
                s+=c*k+d*l
                if w+s<=f and s<=e*w/100 and w!=0 and mx<100*s/(w+s):
                    mx=100*s/(w+s)
                    swmx=w+s
                    smx=s
print(swmx,smx)

Submission status: Wrong Answer

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

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,51):
            for l in range(0,51):
                w=0
                s=0
                w+=100*a*i+100*b*j
                s+=c*k+d*l
                if w+s<=f and s<=e*w/100 and w!=0 and mx<100*s/(w+s):
                    mx=100*s/(w+s)
                    swmx=w+s
                    smx=s
print(swmx,smx)

Submission status: Wrong Answer

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

for i in range(0,31):
    for j in range(0,31):
        for k in range(0,101):
            for l in range(0,101):
                w=0
                s=0
                w+=100*a*i+100*b*j
                s+=c*k+d*l
                if w+s<=f and s<=e*w/100 and w!=0 and mx<100*s/(w+s):
                    mx=100*s/(w+s)
                    swmx=w+s
                    smx=s
print(swmx,smx)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

mx_rate = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        total = (i * A + j * B) * 100
        if total > F:
            continue
        sugar_limit = min(F - total, (total // 100) * E)
        if sugar_limit > 0:
            for k in range(sugar_limit // C + 1):
                sugar_total = k * C
                if sugar_total < sugar_limit:
                    sugar_total += ((sugar_limit - sugar_total) // D) * D
                rate = 100 * sugar_total / (sugar_total + total)
                if rate > mx_rate:
                    mx_rate = rate
                    ans_water = total + sugar_total
                    ans_sugar = sugar_total
print(ans_water, ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

mx_rate = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        total = (i * A + j * B) * 100
        if total > F:
            continue
        sugar_limit = min(F - total, (total // 100) * E)
        if sugar_limit > 0:
            for k in range(sugar_limit // C + 1):
                sugar_total = k * C
                if sugar_total < sugar_limit:
                    sugar_total += ((sugar_limit - sugar_total) // D) * D
                rate = 100 * sugar_total / (sugar_total + total)
                if rate > mx_rate:
                    mx_rate = rate
                    ans_water = total + sugar_total
                    ans_sugar = sugar_total
print(ans_water, ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

mx_rate = 0
ans_water = 0
ans_sugar = 0
for i in range(31):
    for j in range(31):
        total = (i * A + j * B) * 100
        if total > F:
            continue
        sugar_limit = min(F - total, (total // 100) * E)
        if sugar_limit > 0:
            for k in range(sugar_limit // C):
                sugar_total = (k + 1) * C
                if sugar_total < sugar_limit:
                    sugar_total += ((sugar_limit - sugar_total) // D) * D
                rate = 10000000 * sugar_total / (sugar_total + total)
                if rate > mx_rate:
                    mx_rate = rate
                    ans_water = total + sugar_total
                    ans_sugar = sugar_total
print(ans_water, ans_sugar)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

    for p in range(F // (100 * A) + 1):
        for q in range(0, (F - 100 * A * p) // (100 * B) + 1):
            upper = (A * p + B * q) * E
            water = (A * p + B * q) * 100
            if water == 0: continue
            for r in range(0, upper // C + 1):
                if water + C * r > F: continue
                s = (upper - C * r) // D
                while s >= 0 and water + C * r + D * s > F: s -= 1
                if s < 0: continue
                if sugar * (water + C * r + D * s) < (C * r + D * s) * weight:
                    weight = water + C * r + D * s
                    sugar = C * r + D * s
    if sugar == 0:
        print("0 0")
    else:
        print("{} {}".format(weight, sugar))

    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

    for p in range(F // (100 * A) + 1):
        for q in range((F - 100 * A * p) // (100 * B) + 1):
            upper = (A * p + B * q) * E
            water = (A * p + B * q) * 100
            if water == 0: continue
            for r in range(upper // C + 1):
                if water + C * r > F: continue
                s = (upper - C * r) // D
                while water + C * r + D * s > F: s -= 1
                #print("weight, sugar={}, {}".format(water + C * r + D * s, C * r + D * s))
                if sugar * (water + C * r + D * s) < (C * r + D * s) * weight:
                    weight = water + C * r + D * s
                    sugar = C * r + D * s
    if sugar == 0:
        print("0 0")
    else:
        print("{} {}".format(weight, sugar))

    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

    for p in range(F // (100 * A) + 1):
        for q in range((F - 100 * A * p) // (100 * B) + 1):
            upper = (A * p + B * q) * E
            water = (A * p + B * q) * 100
            if water == 0: continue
            for r in range(upper // C + 1):
                if water + r > F: continue
                s = min((upper - C * r) // D, F - (water + r))
                #print("weight, sugar={}, {}".format(water + C * r + D * s, C * r + D * s))
                if sugar * (water + C * r + D * s) < (C * r + D * s) * weight:
                    weight = water + C * r + D * s
                    sugar = C * r + D * s
    if sugar == 0:
        print("0 0")
    else:
        print("{} {}".format(weight, sugar))

    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

    for p in range(F // (100 * A) + 1):
        for q in range((F - 100 * A) // (100 * B) + 1):
            upper = (A * p + B * q) * E
            water = (A * p + B * q) * 100
            if water == 0: continue
            for r in range(upper // C + 1):
                if water + r > F: continue
                s = min((upper - C * r) // D, F - (water + r))
                if s < 0: continue
                if sugar * (water + C * r + D * s) < (C * r + D * s) * weight:
                    weight = water + C * r + D * s
                    sugar = C * r + D * s
    if sugar == 0:
        print("0 0")
    else:
        print("{} {}".format(weight, sugar))

    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

    for p in range(F // (100 * A) + 1):
        for q in range((F - 100 * A) // (100 * B) + 1):
            upper = (A * p + B * q) * E
            water = (A * p + B * q) * 100
            if water == 0: continue
            for r in range(upper // C + 1):
                if water + r > F: continue
                s = min((upper - C * r) // D, F - (water + r))
                if sugar / weight < (C * r + D * s) / (water + C * r + D * s):
                    weight = water + C * r + D * s
                    sugar = C * r + D * s
    print("{} {}".format(weight, sugar))

    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    max_concentration = 0
    ans = (0, 0)
    for a in range(0, F + 1, 100 * A):
        for b in range(0, F - a + 1, 100 * B):
            water = a + b
            if water == 0:
                break
            for c in range(0, F - water + 1, C):
                for d in range(0, F - water - c + 1, D):
                    sugar = c + d
                    if sugar > (water // 100) * E:
                        break
                    concentration = (100 * sugar) / (water + sugar)
                    if concentration > max_concentration:
                        max_concentration = concentration
                        ans = (water + sugar, sugar)

    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import bisect
a,b,c,d,e,f = map(int,input().split())
lw = []
ls = []
for i in range((f//100)//b+1):
    for j in range(100):
        if b*i*100+a*j*100 > f:
            break
        lw.append(b*i*100+a*j*100)
for i in range((f//2)//d+1):
    for j in range(3000):
        if (d*i+c*j) > (f*e)/(100+e):
            break
        ls.append(d*i+c*j)
ls.sort()
lw.sort()
n = len(lw)
ans = 0
ansl = [0,0]

for i in range(n):
    w = lw[i]
    t = min(f-w,w/100*e)
    s = ls[bisect.bisect_right(ls,t)-1]
    if (s+w)==0:
        continue
    if 100*s/(s+w) > ans:
        ans = 100*s/(s+w)
        ansl = [s+w,s]
print(*ansl)

Submission status: Wrong Answer

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

for i in range((F*E//(100+E))//C+1):
    for j in range((F*E//(100+E))//D+1):
        if 0<=i*C+j*D<=F*E/(100+E):
            suger.append(i*C+j*D)
        if i*C+j*D>F*E/(100+E):
            break


c=0
w=100 #初期値に注意！！！！！！
s=0
for i in range(len(water)):
    for j in range(len(suger)):
        if water[i]+suger[j]<=F and water[i]*E/100>=suger[j] and suger[j]/(water[i]+suger[j])>c:
            c=suger[j]/(water[i]+suger[j])
            w=water[i]
            s=suger[j]

print(w+s,s)

Submission status: Wrong Answer

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

for i in range((F*E//(100+E))//C+1):
    for j in range((F*E//(100+E))//D+1):
        if 0<=i*C+j*D<=F*E/(100+E):
            suger.append(i*C+j*D)
        if i*C+j*D>F*E/(100+E):
            break


c=0
w=0
s=0
for i in range(len(water)):
    for j in range(len(suger)):
        if water[i]+suger[j]<=F and water[i]*E/100>=suger[j] and suger[j]/(water[i]+suger[j])>c:
            c=suger[j]/(water[i]+suger[j])
            w=water[i]
            s=suger[j]

print(w+s,s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
water=[]
suger=[]
for i in range(F+1):
    for j in range(F+1):
        if 100*(i*A+j*B)<=F:
            water+=[100*(i*A+j*B)]
for i in range(F+1):
    for j in range(F+1):
        if i*C+j*D<=F:
            suger+=[i*C+j*D]

c=0
w=0
s=0
for i in range(len(water)):
    for j in range(len(suger)):
        if water[i]+suger[j]<=F and water[i]*E/100>=suger[j] and suger[j]>c*(water[i]+suger[j]):
            c=suger[j]/(water[i]+suger[j])
            w=water[i]
            s=suger[j]

print(w+s,s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
water=[]
suger=[]
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        if 100*(i*A+j*B)<=F:
            water+=[100*(i*A+j*B)]
for i in range(F//C+1):
    for j in range(F//D+1):
        if i*C+j*D<=F:
            suger+=[i*C+j*D]

c=0
w=0
s=0
for i in range(len(water)):
    for j in range(len(suger)):
        if water[i]+suger[j]<=F and water[i]*E/100>=suger[j] and suger[j]>c*(water[i]+suger[j]):
            c=suger[j]/(water[i]+suger[j])
            w=water[i]
            s=suger[j]

print(w+s,s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
weight=0
suger=0
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range((i*A+j*B)*E//C+1):
            for l in range((i*A+j*B)*E//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and (i*i+j*j+k*k+l*l)!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print("{} {}".format(weight,suger))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
weight=0
suger=0
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range(F//C+1):
            for l in range(F//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and (i*i+j*j+k*k+l*l)!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print("{} {}".format(weight,suger))

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
weight=0
suger=0
res=False
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range(F//C+1):
            for l in range(F//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and i*i+j*j+k*k+l*l!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print(weight, suger)

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    sugar = set()
    for i in range(F // C + 1):
        for j in range(F // D + 1):
            s = C * i + D * j
            if s <= F:
                sugar.add(s)
            else:
                break

    sugar = sorted(sugar)

    water = set()
    for i in range(F // (100 * A) + 1):
        for j in range(F // (100 * B) + 1):
            w = 100 * A * i + 100 * B * j
            if w <= F:
                water.add(w)
            else:
                break

    water = sorted(water)

    concentration = 0
    ans_water = ans_sugar = 0
    for w in water[1:]:
        s_max = min(F - w, w // 100 * E)
        s = sugar[bisect_right(sugar, s_max) - 1]
        if concentration < 100 * s / (w + s):
            concentration = 100 * s / (w + s)
            ans_water = w
            ans_sugar = s

    print(ans_water + ans_sugar, ans_sugar)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    sugar = set()
    for i in range(F // C + 1):
        for j in range(F // D + 1):
            s = C * i + D * j
            if s <= F:
                sugar.add(s)
            else:
                break

    sugar = sorted(sugar)

    concentration = 0
    ans_water = ans_sugar = 0
    for x in range(F // (100 * A) + 1):
        for y in range(F // (100 * B) + 1):
            water = 100 * A * x + 100 * B * y
            if water > F or water == 0:
                continue
            sugar_max = min(F - water, water // 100 * E)
            s = sugar[bisect_right(sugar, sugar_max) - 1]
            if concentration < 100 * s / (water + s):
                concentration = 100 * s / (water + s)
                ans_water = water
                ans_sugar = s

    print(ans_water + ans_sugar, ans_sugar)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    sugar = set()
    for i in range(F // C + 1):
        for j in range(F // D + 1):
            s = C * i + D * j
            if s <= F:
                sugar.add(s)
            else:
                break

    sugar = sorted(sugar)

    concentration = 0
    ans_water = ans_sugar = 0
    for x in range(F // A + 1):
        for y in range(F // B + 1):
            water = 100 * A * x + 100 * B * y
            if water > F or water == 0:
                continue
            sugar_max = min(F - water, water // 100 * E)
            s = sugar[bisect_right(sugar, sugar_max) - 1]
            if concentration < 100 * s // (water + s):
                concentration = 100 * s // (water + s)
                ans_water = water
                ans_sugar = s

    print(ans_water + ans_sugar, ans_sugar)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    sugar = set()
    for i in range(F // C + 1):
        for j in range(F // D + 1):
            s = C * i + D * j
            if s <= F:
                sugar.add(s)
            else:
                break

    sugar = sorted(sugar)

    concentration = 0
    ans_water = ans_sugar = 0
    for x in range(F // A + 1):
        for y in range(F // B + 1):
            water = 100 * A * x + 100 * B * y
            if water > F or water == 0:
                break
            sugar_max = min(F - water, water // 100 * E)
            s = sugar[bisect_right(sugar, sugar_max) - 1]
            if concentration < 100 * s // (water + s):
                concentration = 100 * s // (water + s)
                ans_water = water
                ans_sugar = s

    print(ans_water + ans_sugar, ans_sugar)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

max_s=0
max_w=1
max_conc=0

water_s=set()
sugar_s=set()
for i in range(f//a//100+1):
  aa=a*i
  for j in range(f//b//100+1):
    bb=b*j
    if aa+bb <= f//100:
      water_s.add(aa+bb)
      
for i in range(f//c+1):
  cc=c*i
  for j in range(f//d+1):
    dd=d*j
    if cc+dd <= f:
      sugar_s.add(cc+dd)

for w in water_s:
  for sg in sugar_s:
    if w*100+sg <= f and w*e >= sg and w+sg > 0:
      conc=(100*sg)/(100*w+sg)
      if max_conc < conc:
        max_conc=conc
        max_w=w
        max_s=sg
print(max_w*100+max_s,max_s)

Submission status: Wrong Answer

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

max_s=0
max_w=0
max_conc=0

water_s=set()
sugar_s=set()
for i in range(f//a//100+1):
  aa=a*i
  for j in range(f//b//100+1):
    bb=b*j
    if aa+bb <= f//100:
      water_s.add(aa+bb)
      
for i in range(f//c+1):
  cc=c*i
  for j in range(f//d+1):
    dd=d*j
    if cc+dd <= f:
      sugar_s.add(cc+dd)

for w in water_s:
  for sg in sugar_s:
    if w*100+sg <= f and w*e >= sg and w+sg > 0:
      conc=(100*sg)/(100*w+sg)
      if max_conc < conc:
        max_conc=conc
        max_w=w
        max_s=sg
      
print(max_w*100+max_s,max_s)

Submission status: Wrong Answer

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

Ws = set()
Ss = set()

for i in range(1,31):
  for j in range(31):
    w = (A*i + B*j)*100
    if w <= F:
      Ws.add(w)
      
i = 1
while C*i <= F:
  j = 0
  while C*i +D*j <= F:
    Ss.add(C*i +D*j)
    j += 1
  i += 1
      
Ws = list(Ws)
Ss = list(Ss)
Ws.sort()
Ss.sort()

W = 0
S = 0
tmp = 0
for w in Ws:
  for s in Ss:
    if w*E >= s*100 and w + s <= F:
      if tmp < s/(s+w):
        W = w
        S = s
        tmp = s/(s+w)
    
print(W+S,S)

Submission status: Wrong Answer

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

Ws = set()
Ss = set()

for i in range(31):
  for j in range(31):
    w = (A*j + B*i)*100
    if w <= F:
      Ws.add(w)
      
i = 0
while C*i <= F//2:
  j = 0
  while C*i +D*j <= F//2:
    Ss.add(C*i +D*j)
    j += 1
  i += 1
      
Ws = list(Ws)
Ss = list(Ss)
Ws.sort()
Ss.sort()

W = 0
S = 0
tmp = 0
for w in Ws[1:]:
  i = bisect.bisect_right(Ss, E*w//100)
  j = bisect.bisect_right(Ss, F - w)
  k = min(i,j)
  if k == 0:
    continue
  if tmp < Ss[k-1]/(Ss[k-1]+w):
    W = w
    S = Ss[k-1]
    tmp = Ss[k-1]/(Ss[k-1]+w)
    
print(W+S,S)

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

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)

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)