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

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

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

ans = [0, 0]
maxc = 0.0
for i, aq in enumerate(AQ):
    for j, sg in enumerate(SG):
        if aq == 0:
            continue
        if aq+sg > F or sg/aq > E/100:
            continue
        if maxc < sg/(aq+sg):
            ans = [aq, sg]
            maxc = sg/(aq+sg)
print(ans[0]+ans[1], ans[1])

Submission status: Wrong Answer

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

def makeSet(a, b):
  list = []
  for i in range(int(F / a + 2)):
    for j in range(int(F / b + 2)):
      tmp = i * a + j * b
      if tmp <= F:
        list.append(tmp)
  return set(list)

W = makeSet(A * 100, B * 100)
S = makeSet(C, D)

def dence(a, b):
  return b * (100 + E) <= E * (a + b)

ma = 100000
mb = 1

def chmax(a, b):
  if b * (ma + mb) >= mb * (a + b):
    return a, b
  return ma, mb

for w in W:
  if w == 0:
    continue
  for s in S:
    if w + s <= F and dence(w, s):
      ma, mb = chmax(w, s)

print(ma + mb, mb)

Submission status: Wrong Answer

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

def makeSet(a, b):
  list = []
  for i in range(int(F / a + 2)):
    for j in range(int(F / b + 2)):
      tmp = i * a + j * b
      if tmp <= F:
        list.append(tmp)
  return set(list)

W = makeSet(A * 100, B * 100)
S = makeSet(C, D)

def dence(a, b):
  return b * (100 + E) <= E * (a + b)

ma = 100000
mb = 1

def chmax(a, b):
  if b * (ma + mb) > mb * (a + b):
    return a, b
  return ma, mb

for w in W:
  for s in S:
    if w + s <= F and dence(w, s):
      ma, mb = chmax(w, s)

print(ma + mb, mb)

Submission status: Wrong Answer

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

def makeSet(a, b):
  list = []
  for i in range(int(F / a + 1)):
    for j in range(int(F / b + 1)):
      tmp = i * a + j * b
      if tmp <= F:
        list.append(tmp)
  return set(list)

W = makeSet(A * 100, B * 100)
S = makeSet(C, D)

def dence(a, b):
  return b * (100 + E) <= E * (a + b)

ma = 10000
mb = 0

def chmax(a, b):
  if b * (ma + mb) > mb * (a + b):
    return a, b
  return ma, mb

for w in W:
  for s in S:
    if w + s <= F and dence(w, s):
      ma, mb = chmax(w, s)

print(str(ma + mb) + ' ' + str(mb))

Submission status: Wrong Answer

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

def makeSet(a, b):
  list = []
  for i in range(int(F / a + 1)):
    for j in range(int(F / b + 1)):
      tmp = i * a + j * b
      if tmp <= F:
        list.append(tmp)
  return set(list)

W = makeSet(A * 100, B * 100)
S = makeSet(C, D)

def dence(a, b):
  return b * (100 + E) <= E * (a + b)

ma = 1000
mb = 0

def chmax(a, b):
  if b * (ma + mb) > mb * (a + b):
    return a, b
  return ma, mb

for w in W:
  for s in S:
    if w + s <= F and dence(w, s):
      ma, mb = chmax(w, s)

print(str(ma + mb) + ' ' + str(mb))

Submission status: Wrong Answer

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

node = 0
aa = 0
bb = 0
cc = 0
dd = 0
na = int(F/(100*A))
nb = int(F/(100*B))
nc = int(F/C)
nd = int(F/D)
for a in range(na+1):
    for b in range(nb+1):
        for c in range(nc+1):
            for d in range(nd+1):
                if 100 * A * a + 100 * B * b + C * c + D * d > F or (A * a + B * b) * E < C * c + D * d:
                    break
                else:
                    if a == b == c == d == 0:
                        continue
                    else:
                        cand = (100 * (C * c + D * d)) / (100 * (A * a + B * b) + (C * c + D * d))
                        if cand > node:
                            node = cand
                            aa = a
                            bb = b
                            cc = c
                            dd = d
print("{} {}".format(100*(A * aa + B * bb)+(C * cc + D * dd), C * cc + D * dd))

Submission status: Wrong Answer

Solution code:
from functools import lru_cache
import sys

sys.setrecursionlimit(1000000)

A,B,C,D,E,F = map(int,input().split())
# (water,sugar)
E2 = 100 * E / (100 + E)

@lru_cache(maxsize=10000)
def dfs(w,s):
    global A,B,C,D,E,F
    #print('dfs',w,s)
    inf = 1 << 60
    if w + s > F:
        return (0, w, s)
    if w + s == 0:
        d = (0, w, s)
    else:
        d = ((100 * s) / (w + s), w, s)
    #print(d)
    d1 = dfs(w + 100*A, s)
    if d1[0] <= E2:
        d = max(d, d1)
    d1 = dfs(w + 100*B, s)
    if d1[0] <= E2:
        d = max(d, d1)
    d1 = dfs(w, s + C)
    if d1[0] <= E2:
        d = max(d, d1)
    d1 = dfs(w, s + D)
    if d1[0] <= E2:
        d = max(d, d1)

    return d

ans = dfs(0,0)
print(ans[1]+ans[2],ans[2])

Submission status: Wrong Answer

Solution code:
EPS = 1E-8
def solve(a, b, c, d, e, f):
    threshold = e / (100 + e) + EPS
    best = -1
    for x in range(0, f+1, 100*a):
        for y in range(x, f+1, 100*b):
            if y == 0:
                continue
            for z in range(y, f+1, c):
                for w in range(z, f+1, d):
                    p = w - y 
                    cur = p / w
                    if best < cur <= threshold:
                        best = cur
                        solution = (p, w)
    return "%d %d" % solution

a, b, c, d, e, f = map(int, input().split())
print(solve(a, b, c, d, e, f))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
aa=0
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,int(e*(i+j)/100)+1,c):
      for l in range(0,int(e*(i+j)/100)+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<(k+l)/(i+j+k+l):
          aa=(k+l)/(i+j+k+l)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
aa=0
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,(i+j)//100*e+1,c):
      for l in range(0,(i+j)//100*e+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<(k+l)/(i+j+k+l):
          aa=(k+l)/(i+j+k+l)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
aa=0
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,e*(i+j)//100+1,c):
      for l in range(0,e*(i+j)//100+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<100*(k+l)/(i+j):
          aa=100*(k+l)/(i+j)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
aa=0
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,e*(i+j)//100+1,c):
      for l in range(0,e*(i+j)//100+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<100*(k+l)//(i+j):
          aa=100*(k+l)//(i+j)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
aa=0
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,e*(i+j)//100+1,c):
      for l in range(0,e*(i+j)//100+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<(k+l)/(i+j):
          aa=(k+l)/(i+j)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
aa=0
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,e*(i+j)//100+1,c):
      for l in range(0,e*(i+j)//100+1-k,d):
        if i+j+k+l>f:
          continue
        if k+l>0 and aa<(k+l)/(i+j+k+l):
          aa=(k+l)/(i+j+k+l)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
aa=0
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,e*(i+j)//100+1,c):
      for l in range(0,e*(i+j)//100+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<(k+l)/(i+j+k+l):
          aa=(k+l)/(i+j+k+l)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
aa=0
ans=[0,0]
for i in range(0,f+1,a*100):
  for j in range(0,f+1-i,b*100):
    for k in range(0,e*(i+j)//100+1,c):
      for l in range(0,e*(i+j)//100+1-k,d):
        if i+j+k+l>f:
          continue
        if i+j>0 and aa<(k+l)/(i+j):
          aa=(k+l)/(i+j+k+l)
          ans=[i+j+k+l,k+l]
print(ans[0],ans[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
EPS = 1E-8
def solve(a, b, c, d, e, f):
    S = set()
    for x in range(0, f+1, 100*a):
        for y in range(0, f+1, 100*b):
            z = x + y
            if 0 < z <= f:
                S.add(z)
    T = set()
    for x in range(0, f+1, c):
        for y in range(0, f+1, d):
            z = x + y
            if z <= f:
                T.add(z)
    threshold = e / (100 + e)
    best = 0
    solution = min(S), min(S)
    for x in S:
        for y in T:
            z = x + y
            cur = y / z
            if (best < cur <= threshold + EPS) and (z <= f):
                best = cur 
                solution = (z, y)
    return "%d %d" % solution

a, b, c, d, e, f = map(int, input().split())
print(solve(a, b, c, d, e, f))

Submission status: Wrong Answer

Solution code:
def solve(a, b, c, d, e, f):
    S = set()
    for x in range(0, f+1, 100*a):
        for y in range(0, f+1, 100*b):
            z = x + y
            if 0 < z <= f:
                S.add(z)
    T = set()
    for x in range(0, f+1, c):
        for y in range(0, f+1, d):
            z = x + y
            if z <= f:
                T.add(z)
    threshold = e / (100 + e)
    best = 0
    solution = 0, 0
    for x in S:
        for y in T:
            z = x + y
            cur = y / z
            if (best < cur <= threshold) and (z <= f):
                best = cur
                solution = (z, y)
    return "%d %d" % solution

a, b, c, d, e, f = map(int, input().split())
print(solve(a, b, c, d, e, f))

Submission status: Wrong Answer

Solution code:
def solve(a, b, c, d, e, f):
    S = set()
    for x in range(0, f, 100*a):
        for y in range(0, f, 100*b):
            z = x + y
            if 0 < z <= f:
                S.add(z)
    T = set()
    for x in range(0, f, c):
        for y in range(0, f, d):
            z = x + y
            if z <= f:
                T.add(z)
    threshold = e / (100 + e)
    best = 0
    solution = 0, 0
    for x in S:
        for y in T:
            z = x + y
            cur = y / z
            if (best < cur <= threshold) and (z <= f):
                best = cur
                solution = (z, y)
    return "%d %d" % solution

a, b, c, d, e, f = map(int, input().split())
print(solve(a, b, c, d, e, f))

Submission status: Wrong Answer

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

con = -1
ans_w, ans_s = 0, 0
for i in range(F//(100*A) + 1):
    water = i*100*A
    for j in range((F-water)//(100*B) + 1):
        if i == 0 and j == 0:
            continue
        water += j*100*B
        for k in range((F-water)//C + 1):
            sugar = k*C
            water += sugar
            if sugar > (A*i+B*j)*E:
                water = i*100*A
                break
            for l in range((F-water)//D + 1):
                sugar += l*D
                water += l*D
                if sugar > (A*i+B*j)*E:
                    water -= sugar
                    break
                tmp = 100*sugar/water
                if tmp > con:
                    con = tmp
                    ans_w = water
                    ans_s = sugar
                water -= l*D
                sugar -= l*D

if ans_s == 0:
    ans_w = 100*A
print(ans_w, ans_s)

Submission status: Wrong Answer

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

con = 0
ans_w, ans_s = 0, 0
for i in range(F//(100*A) + 1):
    water = i*100*A
    for j in range((F-water)//(100*B) + 1):
        if i == 0 and j == 0:
            continue
        water += j*100*B
        for k in range((F-water)//C + 1):
            sugar = k*C
            water += sugar
            if sugar > (A*i+B*j)*E:
                water = i*100*A
                break
            for l in range((F-water)//D + 1):
                sugar += l*D
                water += l*D
                if sugar > (A*i+B*j)*E:
                    water -= sugar
                    break
                tmp = 100*sugar/water
                if tmp > con:
                    con = tmp
                    ans_w = water
                    ans_s = sugar
                water -= l*D
                sugar -= l*D
                    
print(ans_w, ans_s)

Submission status: Wrong Answer

Solution code:

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

con = -1
ans_w, ans_s = 0, 0
for i in range(F//(100*A) + 1):
    water = i*100*A
    for j in range((F-water)//(100*B) + 1):
        if i == 0 and j == 0:
            continue
        water += j*100*B
        for k in range((F-water)//C + 1):
            sugar = k*C
            water += sugar
            if sugar > (A*i+B*j)*E:
                water = i*100*A
                break
            for l in range((F-water)//D + 1):
                sugar += l*D
                water += l*D
                if sugar > (A*i+B*j)*E:
                    water -= sugar
                    break
                tmp = 100*sugar/water
                if tmp > con:
                    con = tmp
                    ans_w = water
                    ans_s = sugar
                water -= l*D
                sugar -= l*D
                    
print(ans_w, ans_s)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
q=[[0,0]]
ans=0
while len(q)>0:
  x,y=q.pop()
  if x+y+100*a<=f:
    q+=[[x+100*a,y]]
  if x+y+100*b<=f:
    q+=[[x+100*b,y]]
  if y+c<=(x-y)*e/100 and x+y+c<=f:
    q+=[[x+c,y+c]]
    ans=max(ans,100*(y+c)/(x+y+c))
  if y+d<=(x-y)*e/100 and x+y+d<=f:
    q+=[[x+d,y+d]]
    ans=max(ans,100*(y+d)/(x+y+d))
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a

import itertools
from collections import Counter
import bisect

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

    ans_nod = 0
    ans_sugar = 0
    ans_water = 0
    for a in range(31):
        for b in range(31):
            water = a * A * 100 + b * B * 100
            if water == 0:
                continue
            if water > F:
                continue
            max_sugar = E * (a * A + b * B)
            for i in range(3000):
                for j in range(3000):
                    sugar = i * C + j * D
                    if sugar > max_sugar:  # 解けないならダメ
                        break
                    if sugar + water > F:  # F超えるならダメ
                        break
                    nod = 100 * sugar / (water + sugar)
                    if nod > ans_nod:
                        ans_nod = nod
                        ans_sugar = sugar
                        ans_water = water
    print("{} {}".format(ans_water + ans_sugar, ans_sugar))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a

import itertools
from collections import Counter
import bisect

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

    ans_nod = 0
    ans_sugar = 0
    ans_water = 0
    for a in range(A+1):
        for b in range(B+1):
            water = a * A * 100 + b * B * 100
            if water == 0:
                continue
            if water > F:
                continue
            max_sugar = E * (a * A + b * B)
            for i in range(3000):
                for j in range(3000):
                    sugar = i * C + j * D
                    if sugar > max_sugar:  # 解けないならダメ
                        break
                    if sugar + water > F:  # F超えるならダメ
                        break
                    nod = 100 * sugar / (water + sugar)
                    if nod > ans_nod:
                        ans_nod = nod
                        ans_sugar = sugar
                        ans_water = water
    print("{} {}".format(ans_water + ans_sugar, ans_sugar))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a

import itertools
from collections import Counter
import bisect

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

    ans_nod = 0
    ans_sugar = 0
    ans_water = 0
    ans_a = 0
    ans_b = 0
    ans_c = 0
    ans_d = 0
    for a in range(A):
        for b in range(B):
            water = a * A * 100 + b * B * 100
            if water == 0:
                continue
            if water > F:
                continue
            max_sugar = E * (a * A + b * B)
            for i in range(3000):
                for j in range(3000):
                    sugar = i * C + j * D
                    if sugar > max_sugar:  # 解けないならダメ
                        break
                    if sugar + water > F:  # F超えるならダメ
                        break
                    nod = 100 * sugar / (water + sugar)
                    if nod > ans_nod:
                        ans_nod = nod
                        ans_sugar = sugar
                        ans_water = water
                        ans_a = a
                        ans_b = b
                        ans_c = i
                        ans_d = j
    print("{} {}".format(ans_water + ans_sugar, ans_sugar))
    # print("{} {} {} {} {} {}".format(ans_water + ans_sugar, ans_sugar, ans_a, ans_b, ans_c, ans_d))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a

import itertools
from collections import Counter
import bisect

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

    ans_nod = 0
    ans_sugar = 0
    ans_water = 0
    for a in range(A):
        for b in range(B):
            water = a * 100 + b * 100
            if water == 0:
                continue
            if water > F:
                continue
            max_sugar = E * (a + b)
            for i in range(3000):
                for j in range(3000):
                    sugar = i * C + j * D
                    if sugar > max_sugar:
                        break
                    if sugar + water > F:
                        continue
                    nod = 100 * sugar / (water + sugar)
                    if nod > ans_nod:
                        ans_nod = nod
                        ans_sugar = sugar
                        ans_water = water
    print("{} {}".format(ans_water + ans_sugar, ans_sugar))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a

import itertools
from collections import Counter
import bisect

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

    ans_nod = 0
    ans_sugar = 0
    ans_water = 0
    for a in range(A):
        for b in range(B):
            water = a * 100 + b * 100
            if water == 0:
                continue
            if water > F:
                continue
            max_sugar = E * (a + b)
            for i in range(3000):
                for j in range(3000):
                    sugar = i * C + j * D
                    if sugar > max_sugar:
                        break
                    nod = 100 * sugar / (water + sugar)
                    if nod > ans_nod:
                        ans_nod = nod
                        ans_sugar = sugar
                        ans_water = water
    print("{} {}".format(ans_water + ans_sugar, ans_sugar))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a

import itertools
from collections import Counter
import bisect

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

    ans_nod = 0
    ans_sugar = 0
    ans_water = 0
    for a in range(A):
        if a * 100 >= F:
            break
        for b in range(B):
            if a * 100 + b * 100 >= F:
                break
            water = a * 100 + b * 100
            if water == 0:
                continue
            max_sugar = E * (a + b)
            for i in range(3000):
                if i * C > max_sugar:
                    break
                for j in range(3000):
                    if i * C + j * D > max_sugar:
                        break
                    sugar = i * C + j * D
                    nod = 100 * sugar / (water + sugar)
                    if nod > ans_nod:
                        ans_nod = nod
                        ans_sugar = sugar
                        ans_water = water
    print("{} {}".format(ans_water + ans_sugar, ans_sugar))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]  # グループ番号
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)


A, B, C, D, E, F = map(int, input().split())
ma = F // (100 * A)
mb = F // (100 * B)
mc = F // C
md = F // D
a = 0
s = 0
d = 0
sw = 0
ss = 0
sd = 0
for i in range(ma + 1):
    if A * 100 * i > F:
        break
    for j in range(mb + 1):
        if A * 100 * i + B * 100 * j > F:
            break
        for k in range(mc + 1):
            if A * 100 * i + B * 100 * j + C * k > F:
                break
            for l in range(md + 1):
                if A * 100 * i + B * 100 * j + C * k + D * l > F:
                    break
                if i + j == 0:
                    break
                a = A * 100 * i + B * 100 * j + C * k + D * l
                s = C * k + D * l
                d = s / (A * i + B * j)
                # print(i, j, a, F, d, E)
                if a <= F and sd < d <= E:
                    sd = d
                    sw = a
                    ss = s
                    # print(a, s, d, i, j)
print(sw, ss)

Submission status: Wrong Answer

Solution code:
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]  # グループ番号
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)


A, B, C, D, E, F = map(int, input().split())
ma = F // (100 * A)
mb = F // (100 * B)
mc = F // C
md = F // D
a = 0
s = 0
d = 0
sw = 0
ss = 0
sd = 0
for i in range(ma + 1):
    if A * 100 * i > F:
        break
    for j in range(mb + 1):
        if A * 100 * i + B * 100 * j > F:
            break
        for k in range(mc + 1):
            if A * 100 * i + B * 100 * j + C * k>F:
                break
            for l in range(md + 1):
                if A * 100 * i + B * 100 * j + C * k + D * l > F:
                    break
                if i + j == 0:
                    continue
                a = A * 100 * i + B * 100 * j + C * k + D * l
                s = C * k + D * l
                d = s / (A * i + B * j)
                #print(i, j, a, F, d, E)
                if a <= F and sd < d <= E:
                    sd = d
                    sw = a
                    ss = s
                    # print(a, s, d, i, j)
print(sw, ss)

Submission status: Wrong Answer

Solution code:
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]  # グループ番号
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)


A, B, C, D, E, F = map(int, input().split())
ma = F // (100 * A)
mb = F // (100 * B)
mc = F // C
md = F // D
a = 0
s = 0
d = 0
sw = 0
ss = 0
sd = 0
for i in range(ma + 1):
    if A * 100 * i > F:
        break
    for j in range(mb + 1):
        if A * 100 * i + B * 100 * j > F:
            break
        for k in range(mc + 1):
            if A * 100 * i + B * 100 * j + C * k>F:
                break
            for l in range(md + 1):
                if A * 100 * i + B * 100 * j + C * k + D * l > F:
                    break
                if i + j == 0:
                    continue
                a = A * 100 * i + B * 100 * j + C * k + D * l
                s = C * k + D * l
                d = s / (A * i + B * j)
                #print(i, j, a, F, d, E)
                if a < F and sd < d <= E:
                    sd = d
                    sw = a
                    ss = s
                    # print(a, s, d, i, j)
print(sw, ss)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math

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

water = []
for ai in range(int(F/(A*100))+1):
    for bi in range(int(F/(B*100))+1):
        if (ai*A+bi*B)*100>F:pass
        else:
            water.append((ai*A+bi*B)*100)

suger = []
for ci in range(int(F/C)+1):
    for di in range(int(F/D)+1):
        if ci*C+di*D > F:
            pass
        else:suger.append(ci*C+di*D)

water = list(set(water))
suger = list(set(suger))
water.remove(0)
pure = 0
ans_s,ans_w = 0,0
for wi in range(len(water)):
    for si in range(len(suger)):
        if water[wi]+suger[si]>F:pass
        else:
            if pure<suger[si]/(water[wi]+suger[si])<=(E/(100+E)):
                ans_s = suger[si]
                ans_w = water[wi]
                pure = suger[si]/(water[wi]+suger[si])

print(ans_s+ans_w,end="")
print(" ",end="")
print(ans_s)

Submission status: Wrong Answer

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

    x = F/(100+E)

    sugar_ws = [C, D]

    for i in range(3001):
        for j in range(i, 3001):
            if C*i + D*j > E*x:
                break
            sugar_ws.append(C*i + D*j)
    
    water_ws = [A*100, B*100]
    for i in range(101):
        for j in range(i, 101):
            if 100*A*i + 100*B*j > 100*x:
                break
            water_ws.append(100*A*i + 100*B*j)
    
    sugar_ws.sort()
    water_ws.sort()
            
    max_w = 0
    max_s = 0
    max_per = 0
    for water_w in water_ws:
        for sugar_w in sugar_ws:
            if water_w + sugar_w > F or sugar_w/E*100 > water_w:
                break

            if (sugar_w + water_w) != 0 and (100*sugar_w)/(sugar_w+water_w) > max_per:
                max_per = (100*sugar_w)/(sugar_w+water_w)
                max_s = sugar_w
                max_w = water_w
    
    print("{} {}".format((max_s+max_w), max_s))

main()