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())
noudomax=0
weight=0
weightmax=0
sugarmax=0
i=0
while True:
    weight=a*100*i
    if weight>f:
        break
    j=0
    while True:
        if i==j==0:
            j+=1
            continue
        weight=a*100*i+b*100*j
        if weight>f:
            break
        k=0
        while True:
            weight=a*100*i+b*100*j+c*k
            if weight>f:
                break
            l=0
            while True:
                weight=a*100*i+b*100*j+c*k+d*l
                sugar=c*k+d*l
                if weight>f:
                    break
                noudo=100*sugar/weight
                if noudomax<noudo<=100*e/(e+100):
                    #print(noudo,i,j,k,l)
                    weightmax=weight
                    sugarmax=sugar
                    noudomax=noudo
                l+=1
            k+=1
        j+=1
    i+=1

print(weightmax,sugarmax)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
noudomax=0
weight=0
weightmax=0
sugarmax=0
i=0
while True:
    j=0
    weight=a*100*i
    if weight>f:
        break
    while True:
        k=0
        weight=a*100*i+b*100*j
        if weight>f:
            break
        while True:
            l=0
            weight=a*100*i+b*100*j+c*k
            if weight>f:
                break
            while True:
                weight=a*100*i+b*100*j+c*k+d*l
                sugar=c*k+d*l
                if weight>f:
                    break
                if weight==0:
                    l+=1
                    continue
                noudo=100*sugar/weight
                if noudomax<noudo<=e:
                    #print(noudo,i,j,k,l)
                    weightmax=weight
                    sugarmax=sugar
                l+=1
            k+=1
        j+=1
    i+=1

print(weightmax,sugarmax)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
a=a*100
b=b*100
pair=[]
nd = []
for i in range(10):
  for j in range(10):
    for k in range(10):
      for l in range(10):
        if a*i+b*j+c*k+d*l<=f and i+j+k+l>0:
          pair.append([(c*k+d*l)/(a*i+b*j+c*k+d*l),i,j,k,l])
          nd.append((c*k+d*l)/(a*i+b*j+c*k+d*l))
for i in pair:
  if i[0]==max(nd):
    print(a*i[1]+b*i[2]+c*i[3]+d*i[4],c*i[3]+d*i[4])
    exit()

Submission status: Wrong Answer

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

ans, cont = [0]*2, 0

for i in range(f//100+1):
    if i%a == 0 or i%b == 0:
        water = i*100
        x = min(f-water, i*e)

        suger = 0

        for j in range(x//c+1):
            s3 = j*c
            suger = max(suger, s3+((x-s3)//d)*d)

        if water != 0:
            if cont <= 100*suger / water+suger:
                ans = [water, suger]
                cont = 100*suger / water+suger

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

Submission status: Wrong Answer

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

ans, cont = [0]*2, 0

for i in range(1, f//100+1):
    if i%a == 0 or i%b == 0:
        water = i*100
        x = min(f-water, i*e)

        suger = 0

        for j in range(1, x//c+1):
            s3 = j*c
            suger = max(suger, s3+((x-s3)//d)*d)

        if water != 0:
            if cont <= 100*suger / water+suger:
                ans = [water, suger]
                cont = 100*suger / water+suger

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

Submission status: Wrong Answer

Solution code:
inlst = list(map(int, input().split()))
ans1 = 0
ans2 = 0
cnt1 = inlst[0] * inlst[4]
if cnt1 + inlst[0] > inlst[-1]:
    cnt1 = inlst[-1] - inlst[0]
wcnt1 = (cnt1 // inlst[2] + 1)
fcnt = wcnt1
roopcnt = inlst[-1] // (cnt1 + 100 * inlst[0])
def ansloop(wcnt1, fcnt, n):
    wcnt1 *= n
    fcnt *= n
    tans = 0
    while wcnt1 >= 0:
        tmpans = wcnt1 * inlst[2]
        if tmpans <= cnt1 * n:
            tmp = tmpans
            for i in range(fcnt):
                tmp += inlst[3]
                if tmp <= cnt1 * n:
                    tmpans = tmp
                else:
                    break
            tans = max(tans, tmpans)
        wcnt1 -= 1
    return tans
index = 1
for i in range(1, roopcnt + 1):
    tmp = ansloop(wcnt1, fcnt, i)
    if (100 * ans1) / (index * 100 * inlst[0] + ans1) < (100 * tmp) / (i * 100 * inlst[0] + tmp):
        ans1 = tmp
        index = i
print(100 * inlst[0] * index + ans1, ans1)

Submission status: Wrong Answer

Solution code:
inlst = list(map(int, input().split()))
ans1 = 0
ans2 = 0
cnt1 = inlst[0] * inlst[4]
if cnt1 + inlst[0] > inlst[-1]:
    cnt1 = inlst[-1] - inlst[0]
wcnt1 = (cnt1 // inlst[2] + 1)
fcnt = wcnt1
while wcnt1 >= 0:
    tmpans = wcnt1 * inlst[2]
    if tmpans <= cnt1:
        tmp = tmpans
        for i in range(fcnt):
            tmp += inlst[3]
            if tmp <= cnt1:
                tmpans = tmp
            else:
                break
        ans1 = max(ans1, tmpans)

    wcnt1 -= 1

print(100 * inlst[0] + ans1, ans1)

Submission status: Wrong Answer

Solution code:

atof = list(map(int,input().split()))
a=atof[0]
b=atof[1]
c=atof[2]
d=atof[3]
e=atof[4]
f=atof[5]
x=[]
y=[]
beaker=0
water=0#100(x*a + y*b)
sugar=0#z*c + w*d
act_melt = 0#(x*a + y*b)*e
# sugar<=act_melt
# beaker<=f 
for i in range(f):
  for j in range(f):
    if i*c + j*d<=f:
      y.append(i*c + j*d)

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

maxSuWa = x[0] + y[0]
maxSugar = y[0]
for i in range(len(x)):
  for j in range(len(y)):
    sugar = y[j]
    water = x[i]
    act_melt = (water//100)*e
    beaker = sugar + water
    if beaker <= f and sugar <= act_melt and maxSuWa<beaker and maxSugar<sugar:
      maxSuWa = beaker
      maxSugar = sugar
print(maxSuWa,maxSugar)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B, C, D, E, F = map(int, input().split(' '))

watars = []
import math
for i in range(int(math.floor(F/ (A*100)))+1):
    rest = F - A * 100 * i
    for j in range(int(math.floor(rest/ (B*100)))+1):
        watars.append(A*100*i + B*100*j)

salts = []
lim_salt = int(F * E // 100)
for i in range(int(math.floor(lim_salt/ C))+1):
    rest = lim_salt - C * i
    for j in range(int(math.floor(rest/ D))+1):
        salts.append(C*i + D*j)

watars = set(watars)
salts = set(salts)

# print(len(watars), len(salts))

max_ratio = 0
ans = [0, 0]
for watar in watars:
    if watar == 0:
        continue

    for salt in salts:
        amount = watar + salt
        ratio = salt / amount
        if amount <= F and salt <= watar * E / 100:
            if ratio > max_ratio:
                max_ratio = ratio
                ans = [watar, salt]

if max_ratio == 0:
    print(min(watars), 0)

else:
    print(sum(ans), ans[1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B, C, D, E, F = map(int, input().split(' '))

watars = []
import math
for i in range(int(math.floor(F/ (A*100)))+1):
    rest = F - A * 100 * i
    for j in range(int(math.floor(rest/ (B*100)))+1):
        watars.append(A*100*i + B*100*j)

salts = []
lim_salt = int(F * E // 100)
for i in range(int(math.floor(lim_salt/ C))+1):
    rest = lim_salt - C * i
    for j in range(int(math.floor(rest/ D))+1):
        salts.append(C*i + D*j)

watars = set(watars)
salts = set(salts)

# print(len(watars), len(salts))

max_ratio = 0
ans = [0, 0]
for watar in watars:
    if watar == 0:
        continue

    for salt in salts:
        amount = watar + salt
        ratio = salt / amount
        if amount <= F and salt <= watar * E / 100:
            if ratio > max_ratio:
                max_ratio = ratio
                ans = [watar, salt]

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

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a, b = a*100, b*100
limit_a = f//a +1
limit_b = f//b +1
limit_c = f//c +1
limit_d = f//d +1

rslt = 0
r_solt = 0
r_all = 0
for i in range(limit_a):
    for j in range(limit_b):

        water = a*i + b*j
        if water == 0 or water > f:break

        for k in range(limit_c):
            for l in range(limit_d):

                solt = c*k + d*l
                all = water + solt
                if all > f :break
                elif solt/water*100 < e:
                    if(rslt < solt/water):
                        r_solt = solt
                        r_all = all
                        rslt = solt/water                        
                elif solt/water*100 == e:
                    print("{} {}".format(all, solt))
                    exit()
                else :break

print("{} {}".format(r_all, r_solt))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a = a*100
b = b*100
limit_a = f//a +1
limit_b = f//b +1
limit_c = f//c +1
limit_d = f//d +1

rslt = 0
for i in range(limit_a):
    for j in range(limit_b):
        for k in range(limit_c):
            water = a*i + b*j
            if water == 0:break
            for l in range(limit_d):
                solt = c*k + d*l
                all = water + solt
                if all > f :break
                elif solt/water*100 <= e:
                    rslt = max(rslt,solt/water)
                    if(rslt == solt/water):
                        r_solt = solt
                        r_all = all
                else:break
print("{} {}".format(r_all, r_solt))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a = a*100
b = b*100
limit_a = f//a +1
limit_b = f//b +1
limit_c = f//c +1
limit_d = f//d +1

rslt = 0
for i in range(limit_a):
    for j in range(limit_b):
        for k in range(limit_c):
            for l in range(limit_d):
                water = a*i + b*j
                solt = c*k + d*l
                all = water + solt
                if all > f or water == 0:break
                elif solt/water*100 < e:
                    rslt = max(rslt,solt/water)
                    if(rslt == solt/water):
                        r_solt = solt
                        r_all = all
print("{} {}".format(r_all, r_solt))

Submission status: Wrong Answer

Solution code:
import sys


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

    # sum(ABCD) < F
    # sum(AB) * E <= sum(CD)

    max_dense = 0
    result = (0, 0)
    AB = sorted(list(set([a for a in range(0, int(F / 100) + 1, A)] + [b for b in range(0, int(F / 100) + 1, B)])))
    for water in AB:
        if water == 0:
            continue
        c = 0
        while water * 100 + c <= F and c <= water * E:
            d = 0
            while water * 100 + c + d <= F and c + d <= water * E:
                sugar = c + d
                total = water * 100 + sugar
                dense = 100 * sugar / total
                if dense > max_dense:
                    # print("{} {} {} {} : {}".format(total, water * 100, c, d, dense))
                    max_dense = dense
                    result = (total, sugar)
                d += D
            c += C

    return "{} {}".format(result[0], result[1])


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys


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

    # sum(ABCD) < F
    # sum(AB) * E <= sum(CD)

    max_dense = 0
    result = (0, 0)
    AB = sorted(list(set([a for a in range(0, int(F / 100) + 1, A)] + [b for b in range(0, int(F / 100) + 1, B)])))
    for water in AB:
        if water == 0:
            continue
        sugar_max = min(water * E, F - water * 100)
        for c in range(0, sugar_max + 1, C):
            d = int((sugar_max - c) / D) * D
            sugar = c + d
            total = water * 100 + sugar
            dense = 100 * sugar / (total)
            # print("{} {} {} : {}".format(water * 100, c, d, dense))
            if dense > max_dense:
                max_dense = dense
                result = (total, sugar)

    return "{} {}".format(result[0], result[1])


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys


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

    # sum(ABCD) < F
    # sum(AB) * E <= sum(CD)

    max_dense = 0
    result = (0, 0)
    AB = sorted(list(set([a for a in range(0, int(F / 100) + 1, A)] + [b for b in range(0, int(F / 100) + 1, B)])))
    for water in AB:
        if water == 0:
            continue
        sugar_max = water * E
        for c in range(0, sugar_max + 1, C):
            d = int((sugar_max - c) / D) * D
            sugar = c + d
            if water * 100 + sugar > F:
                continue
            dense = sugar / (water * 100 + sugar)
            # print("{} {} {} : {}".format(water * 100, c, d, dense))
            if dense > max_dense:
                max_dense = dense
                result = (water * 100 + sugar, sugar)

    return "{} {}".format(result[0], result[1])


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
possible_x = set()
possible_y = set()
for i in range(32):
    for j in range(32):
        value = i*100*A+j*100*B
        if value <= F:
            possible_x.add(value)
for i in range(3001//C+10):
    for j in range(3001//D+10):
        value = C*i+D*j
        if value <= F:
            possible_y.add(value)
max_density = 0
max_water = 0
max_sugar = 0
for x in possible_x:
    for y in possible_y:
        if x+y > F:
            pass
        elif E*x/100 < y:
            pass
        else:
            if x+y == 0:
                pass
            elif (100*y)/(x+y) > max_density:
                max_density = (100*y)/(x+y)
                max_water = x
                max_sugar = y
print(max_water+max_sugar,max_sugar)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
possible_x = set()
possible_y = set()
for i in range(31):
    for j in range(31):
        value = i*100*A+j*100*B
        if value <= F:
            possible_x.add(value)
for i in range(3001//C+1):
    for j in range(3001//D+1):
        value = C*i+D*j
        if value <= F:
            possible_y.add(value)
max_density = 0
max_water = 0
max_sugar = 0
for x in possible_x:
    for y in possible_y:
        if x+y > F or x+y == 0:
            pass
        elif E*x/100 < y:
            pass
        else:
            if (100*y)/(x+y) > max_density:
                max_density = (100*y)/(x+y)
                max_water = x
                max_sugar = y
print(max_water+max_sugar,max_sugar)

Submission status: Wrong Answer

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

max_density = 0
ans_water = 0
ans_sugar = 0
for op_A in range(30):
    for op_B in range(30):
        water_weight = op_A*A*100 + op_B*B*100
        max_sugar_weight = E*water_weight//100
        if water_weight > F or water_weight == 0:
            continue
        for i in range(max_sugar_weight//C+1):
            for j in range(max_sugar_weight//D+1):
                sugar_weight = i*C + j*D
                if (100*sugar_weight)/(water_weight+sugar_weight) > max_density and (water_weight+sugar_weight) <= F:
                    ans_water = water_weight
                    ans_sugar = sugar_weight
                    max_density = (100*sugar_weight)/(water_weight+sugar_weight)
print(ans_water+ans_sugar,ans_sugar)

Submission status: Wrong Answer

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

for a in range(31):
    for b in range(31):
        if a==0 and b==0:
            continue
        
        for c in range(3001):
            for d in range(3001):
                water = 100*A*a+100*B*b
                sugar = C*c+D*d
                
                if water+sugar>F:
                    break
                
                if sugar>(A*a+B*b)*E:
                    break
                
                if sugar*ans0>ans1*(water+sugar):
                    ans0 = water+sugar
                    ans1 = sugar

print(ans0, ans1)

Submission status: Wrong Answer

Solution code:
def main():
    a,b,c,d,e,f=map(int,input().split())
    con=0
    ans1,ans2=0,0
    for i in range(30):
        for j in range(30):
            if i==j==0:continue
            for k in range(3000):
                for l in range(3000):
                    if i==j==k==l==0: continue
                    s = c*k+d*l    
                    sw = (a*i+b*j)*100+s
                    tmp=100*s/sw
                    if sw<=f and tmp<=100*e/(100+e):
                        if con<tmp:
                            con=tmp
                            ans1=sw
                            ans2=s
                    else:
                        break
    print(ans1,ans2)
main()

Submission status: Wrong Answer

Solution code:
def main():
    a,b,c,d,e,f=map(int,input().split())
    con=0
    ans1,ans2=0,0
    for i in range(30):
        for j in range(30):
            if i==j==0:continue
            for k in range(3000):
                for l in range(3000):
                    if i==j==k==l==0: continue
                    s = c*k+d*l    
                    sw = (a*i+b*j)*100+s
                    tmp=100*s//sw
                    if sw<=f and tmp<=100*e//(100+e):
                        if con<tmp:
                            con=tmp
                            ans1=sw
                            ans2=s
                    else:
                        break
    print(ans1,ans2)
main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def can_make(num, a, b):
    while num >= 0:
        if num % a == 0 or num % b == 0:
            return True
        num -= a
    return False

def main():
    A, B, C, D, E, F = LI()
    if A > B:
        A, B = B, A
    if C > D:
        C, D = D, C
    max_perc = -1
    max_sugar = -1
    max_water = -1
    for unit in range(A, 31):
        water = unit * 100
        for sugar in range(min(F - water, unit*E)+1):
            if can_make(sugar, C, D) and can_make(water, A, B):
                perc = sugar/(sugar + water)
                if perc > max_perc:
                    max_perc = perc
                    max_sugar = sugar
                    max_water = water
    print(max_water + max_sugar, max_sugar)

main()

Submission status: Wrong Answer

Solution code:
import copy
a, b, c, d, e, f=map(int, input().split())
def g(x, y):
  if y==0:
    return 0
  else:
    return x/y
maxnodo=0
q_max=f//(100*b)
for q in range(q_max, -1, -1):
  p_max=(f-100*b*q)//(100*a)
  for p in range(p_max, -1, -1):
    s_max=min((f-(a*p+b*q)*100)//d, e*(a*p+b*q)//d)
    for s in range(s_max, -1, -1):
      r=(f-((a*p+b*q)*100+d*s))//c
      nodo=g(c*r+d*s, (a*p+b*q)*100+c*r+d*s)
      while r>0 and nodo>e/(100+e):
        r-=1
        nodo=g(c*r+d*s, (a*p+b*q)*100+c*r+d*s)
      if nodo>=maxnodo:
        out=[(a*p+b*q)*100+c*r+d*s, c*r+d*s]
        maxnodo=copy.copy(nodo)
        
print(*out)

Submission status: Wrong Answer

Solution code:
import copy
a, b, c, d, e, f=map(int, input().split())
def g(x, y):
  if y==0:
    return 0
  else:
    return x/y
maxnodo=0
q_max=f//(100*b)
for q in range(q_max, -1, -1):
  p_max=(f-100*b*q)//(100*a)
  for p in range(p_max, -1, -1):
    s_max=min((f-(a*p+b*q)*100)//d, e*(a*p+b*q)//d)
    for s in range(s_max, -1, -1):
      r=min(max((f-((a*p+b*q)*100+d*s))//c, 0), max(((a*p+b*q)*e-s*d)//c, 0))
      nodo=g(c*r+d*s, (a*p+b*q)*100+c*r+d*s)
      if nodo>=maxnodo:
        out=[(a*p+b*q)*100+c*r+d*s, c*r+d*s]
        maxnodo=copy.copy(nodo)
        
print(*out)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,d,e,f = LI()
    ans = 0
    p = [a,0]
    n = 31
    for x in range(n):
        A = a*x
        for y in range(n):
            B = b*y
            s = A+B
            r = min(f-100*s,s*e)
            if r > 0:
                for z in range(r+1):
                    C = c*z
                    rest = r-C
                    if rest < 0:
                        break
                    w = rest//d
                    D = d*w
                    res = (C+D)/(100*s+C+D)
                    if ans < res:
                        ans = res
                        p[0] = 100*s+C+D
                        p[1] = C+D
    print(*p)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,d,e,f = LI()
    ans = 0
    p = [0,0]
    n = 31
    A = -a
    for x in range(n):
        B = -b
        A += a
        for y in range(n):
            if x == y == 0:
                continue
            B += b
            s = A+B
            r = min(f-100*s,s*e)
            if r > 0:
                C = -c
                for z in range(r+1):
                    C += c
                    rest = r-C
                    if rest < 0:
                        continue
                    w = rest//d
                    D = d*w
                    res = (C+D)/(100*s+C+D)
                    if ans < res:
                        ans = res
                        p[0] = 100*s+C+D
                        p[1] = C+D
    print(*p)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,d,e,f = LI()
    ans = 0
    p = [0,0]
    n = 31
    A = -a
    for x in range(n):
        B = -b
        A += a
        for y in range(n):
            if x == y == 0:
                continue
            B += b
            s = A+B
            r = min(f-100*s,s*e)
            if r > 0:
                C = -c
                for z in range(r+1):
                    C += c
                    rest = r-C
                    if rest < 0:
                        break
                    w = rest//d
                    D = d*w
                    res = (C+D)/(100*s+C+D)
                    if ans < res:
                        ans = res
                        p[0] = 100*s+C+D
                        p[1] = C+D
    print(*p)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,d,e,f = LI()
    ans = 0
    p = [0,0]
    n = 31
    A = -a
    for x in range(n):
        B = -b
        A += a
        for y in range(n):
            if x == y == 0:
                continue
            B += b
            s = A+B
            r = min(f-100*s,s*e)
            if r > 0:
                C = -c
                for z in range(r):
                    C += c
                    rest = r-C
                    if rest < 0:
                        break
                    w = rest//d
                    D = d*w
                    res = (C+D)/(100*s+C+D)
                    if ans < res:
                        ans = res
                        p[0] = 100*s+C+D
                        p[1] = C+D
    print(*p)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

SIZE = 3001
W = [0] * SIZE
S = [0] * SIZE

W[A * 100] = 1
W[B * 100] = 1
S[0] = 1

for i in range(SIZE):
  if W[i]:
    if i + A * 100 < SIZE:
      W[i + A * 100] = 1
    if i + B * 100 < SIZE:
      W[i + B * 100] = 1
  if S[i]:
    if i + C < SIZE:
      S[i + C] = 1
    if i + D < SIZE:
      S[i + D] = 1
  
water = []
sugar = []
for i in range(SIZE):
  if W[i] and i <= F:
    water.append(i)
  if S[i] and i <= F:
    sugar.append(i)
#print("water:", water)
#print("sugar:", sugar)

max_pp = -1
wss = (0, 0)
for w in water:
  for s in sugar:
    p = s / w * 100
    pp = s / (s + w) * 100
    if w + s <= F and p <= E:
      if max_pp < pp:
        max_pp = pp
        wss = (w + s, s)
print(*wss)

Submission status: Wrong Answer

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

SIZE = 3001
W = [0] * SIZE
S = [0] * SIZE

W[A * 100] = 1
W[B * 100] = 1
S[0] = 1

for i in range(SIZE):
  if W[i]:
    if i + A * 100 < SIZE:
      W[i + A * 100] = 1
    if i + B * 100 < SIZE:
      W[i + B * 100] = 1
  if S[i]:
    if i + C < SIZE:
      S[i + C] = 1
    if i + D < SIZE:
      S[i + D] = 1
  
water = []
sugar = []
for i in range(SIZE):
  if W[i] and i <= F:
    water.append(i)
  if S[i] and i <= F:
    sugar.append(i)
#print("water:", water)
#print("sugar:", sugar)

max_p = -1
wss = (0, 0)
for w in water:
  for s in sugar:
    p = s / w * 100
    if w + s <= F and p <= E:
      if max_p < p:
        max_p = p
        wss = (w + s, s)
print(*wss)

Submission status: Wrong Answer

Solution code:



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

# 作りうる水の量を洗い出す
waters = set()

for i in range(F//(100*A) + 1):
    for j in range((F-100*A*i)//(100*B) + 1):
        w = 100*A*i + 100*B*j
        if w != 0:
            waters.add(w)
waters = list(waters)
waters.sort()


sugars = set()
# Cを何回入れるか
for i in range(F//C + 1):
    # Dを何回いれるか
    for j in range((F - C*i) // D + 1):
        s = i*C + j*D
  
        sugars.add(s)


sugars = list(sugars)
sugars.sort()

# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
water = 0
sugar = 0




for w in waters:
    for s in sugars:

        # 容量を超えたらアウト
        if w+s > F: break
        # 解けきれない量でもアウト
        if s*100 > w * E: break

        conc = s / (s+w)
        if conc > max_conc:
            max_conc = conc
            water = w
            sugar = s

print(sugar+water, sugar)