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:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc074/tasks/arc083_a
# 要復習
A, B, C, D, E, F = read_ints()


# Aを何回を行うか Bを何回行うかは全探索できる #30通り*30通り(たかだか)
satou_candi = set()
for c, d in product(range(3001), repeat=2):
    if c * C + d * D > F:
        continue
    satou_candi.add(c * C + d * D)

water_candi = set()
for a, b in product(range(31), repeat=2):
    if 100 * (A * a + B * b) > F:
        continue
    water_candi.add((A * a + B * b) * 100)

satou_candi = sorted(satou_candi)
water_candi = sorted(water_candi)
# print(satou_candi)
# print(water_candi)

ans_satou = 0
ans_total = A * 100

for water in water_candi[1:]:
    max_satou = E * water // 100  # 100lあたり
    idx = bisect_right(satou_candi, max_satou) - 1  # -1にはならないはず [0]→0なので
    satou = satou_candi[idx]
    # print(water, satou, max_satou)
    if max_satou + water > F:
        continue
    if ans_satou / ans_total < satou / (satou + water):
        ans_satou = satou
        ans_total = water + satou

print(ans_total, ans_satou)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc074/tasks/arc083_a
# 要復習
A, B, C, D, E, F = read_ints()


# Aを何回を行うか Bを何回行うかは全探索できる #30通り*30通り(たかだか)
satou_candi = set()
for c, d in product(range(3000), repeat=2):
    if c * C + d * D > F:
        continue
    satou_candi.add(c * C + d * D)

water_candi = set()
for a, b in product(range(30), repeat=2):
    if 100 * (A * a + B * b) > F:
        continue
    water_candi.add((A * a + B * b) * 100)

satou_candi = sorted(satou_candi)
water_candi = sorted(water_candi)
# print(satou_candi)
# print(water_candi)

ans_satou = 0
ans_total = A * 100

for water in water_candi[1:]:
    max_satou = E * water // 100  # 100lあたり
    idx = bisect_right(satou_candi, max_satou) - 1  # -1にはならないはず [0]→0なので
    satou = satou_candi[idx]
    # print(water, satou, max_satou)
    if max_satou + water > F:
        continue
    if ans_satou / ans_total < satou / (satou + water):
        ans_satou = satou
        ans_total = water + satou

print(ans_total, ans_satou)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc074/tasks/arc083_a
# 要復習
A, B, C, D, E, F = read_ints()


# Aを何回を行うか Bを何回行うかは全探索できる #30通り*30通り(たかだか)
satou_candi = set()
for c, d in product(range(3000), repeat=2):
    if c * C + d * D > F:
        continue
    satou_candi.add(c * C + d * D)

water_candi = set()
for a, b in product(range(30), repeat=2):
    if 100 * (A * a + B * b) > F:
        continue
    water_candi.add((A * a + B * b) * 100)

satou_candi = sorted(satou_candi)
water_candi = sorted(water_candi)
# print(satou_candi)
# print(water_candi)

ans_satou = 0
ans_total = 1

for water in water_candi[1:]:
    max_satou = E * water // 100  # 100lあたり
    idx = bisect_right(satou_candi, max_satou) - 1  # -1にはならないはず [0]→0なので
    satou = satou_candi[idx]
    # print(water, satou, max_satou)
    if max_satou + water > F:
        continue
    if ans_satou / ans_total < satou / (satou + water):
        ans_satou = satou
        ans_total = water + satou

print(ans_total, ans_satou)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc074/tasks/arc083_a
# 要復習
A, B, C, D, E, F = read_ints()


# Aを何回を行うか Bを何回行うかは全探索できる #30通り*30通り(たかだか)
# c,dを何回行うかは事前に作っておけば二分探索でギリギリのを求められる
satou_candi = set()
for c, d in product(range(3000), repeat=2):
    if c * C + d * D > F:
        continue
    satou_candi.add(c * C + d * D)

water_candi = set()
for a, b in product(range(30), repeat=2):
    if 100 * (A * a + B * b) > F:
        continue
    water_candi.add(A * a + B * b)

satou_candi = sorted(satou_candi)
water_candi = sorted(water_candi)

ans = (0, 1)

for water in water_candi:
    max_satou = E * water  # 100lあたり
    idx = bisect_left(satou_candi, max_satou) - 1
    if idx == -1:
        continue
    satou = satou_candi[idx]
    if max_satou + water * 100 > F:
        continue
    if ans[0] / (ans[0] + ans[1] * 100) < satou / (satou + water * 100):
        ans = (satou, water)

print(ans[1] * 100 + ans[0], ans[0])

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    A, B, C, D, E, F = map(int, input().split())
    waters = set()
    for i in range(0, F, A):
        for j in range(0, F, B):
            ij = i * 100 + j * 100
            if ij > F:
                break
            waters.add(ij)
    sugers = set()
    for i in range(0, F, C):
        for j in range(0, F, D):
            ij = i + j
            if ij > F:
                break
            sugers.add(ij)
    ans_water = 0
    ans_suger = 0
    ans = 0
    for water in waters:
        for suger in sugers:
            if water + suger == 0:
                continue
            if water + suger > F:
                continue
            if 100 * suger > E * water:
                continue
            if 100 * suger / (water + suger) > ans:
                ans = 100 * suger / (water + suger)
                ans_water = water
                ans_suger = suger
    if ans_suger == 0:
        if A ** 100 <= F:
            raise ValueError
            print(A*100, 0)
        elif B * 100 <= F:
            print(B*100, 0)
        else:
            print(0, 0)
    else:
        print(ans_water+ans_suger, ans_suger)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    A, B, C, D, E, F = map(int, input().split())
    waters = set()
    for i in range(0, F, A):
        for j in range(0, F, B):
            ij = i * 100 + j * 100
            if ij > F:
                break
            waters.add(ij)
    sugers = set()
    for i in range(0, F, C):
        for j in range(0, F, D):
            ij = i + j
            if ij > F:
                break
            sugers.add(ij)
    ans_water = 0
    ans_suger = 0
    ans = 0
    for water in waters:
        for suger in sugers:
            if water + suger == 0:
                continue
            if water + suger > F:
                continue
            if 100 * suger > E * water:
                continue
            if 100 * suger / (water + suger) > ans:
                ans = 100 * suger / (water + suger)
                ans_water = water
                ans_suger = suger
    if ans_suger == 0:
        if A ** 100 <= F:
            print(A*100, 0)
        elif B * 100 <= F:
            print(B*100, 0)
        else:
            print(0, 0)
    else:
        print(ans_water+ans_suger, ans_suger)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    A, B, C, D, E, F = map(int, input().split())
    waters = set()
    for i in range(0, F, A):
        for j in range(0, F, B):
            ij = i * 100 + j * 100
            if ij > F:
                break
            waters.add(ij)
    sugers = set()
    for i in range(0, F, C):
        for j in range(0, F, D):
            ij = i + j
            if ij > F:
                break
            sugers.add(ij)
    ans_water = 0
    ans_suger = 0
    ans = 0
    for water in waters:
        for suger in sugers:
            if water + suger == 0:
                continue
            if water + suger > F:
                continue
            if 100 * suger > E * water:
                continue
            if 100 * suger / (water + suger) > ans:
                ans = 100 * suger / (water + suger)
                ans_water = water
                ans_suger = suger
    print(ans_water+ans_suger, ans_suger)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def total_check(sugar, water, lim):
    if sugar + water <= lim:
        return True
    else:
        return False


def concentration(sugar, water, lim_sugar):
    if sugar / (sugar + water) <= lim_sugar / (lim_sugar + 100):
        return True
    else:
        return False


def main():
    a, b, c, d, lim_sugar, lim = map(int, input().split())
    water_list = []
    for i in range(lim // (100 * a) + 1):
        for j in range(lim // (100 * b) + 1):
            water_list.append(100 * i * a + 100 * j * b)
    water_list = sorted(list(set(water_list)))
    sugar_list = []
    for i in range(lim // c + 1):
        for j in range(lim // d + 1):
            sugar_list.append(i * c + j * d)
    sugar_list = sorted(list(set(sugar_list)))
    c = 0
    ans = (a, 0)
    for w in water_list:
        for s in sugar_list:
            if w == 0 and s == 0: continue
            if total_check(s, w, lim) and concentration(s, w, lim_sugar):
                if c < s * 100 / (s + w):
                    c = s * 100 / (s + w)
                    ans = (s+w, s)
    print(*ans)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def total_check(sugar, water, lim):
    if sugar + water <= lim:
        return True
    else:
        return False


def concentration(sugar, water, lim_sugar):
    if sugar / (sugar + water) <= lim_sugar / (lim_sugar + 100):
        return True
    else:
        return False


def main():
    a, b, c, d, lim_sugar, lim = map(int, input().split())
    water_list = []
    for i in range(lim // (100 * a) + 1):
        for j in range(lim // (100 * b) + 1):
            water_list.append(100 * i * a + 100 * j * b)
    water_list = sorted(list(set(water_list)))
    sugar_list = []
    for i in range(lim // c + 1):
        for j in range(lim // d + 1):
            sugar_list.append(i * c + j * d)
    sugar_list = sorted(list(set(sugar_list)))
    c = 0
    ans = (0, 0)
    for w in water_list:
        for s in sugar_list:
            if w == 0 and s == 0: continue
            if total_check(s, w, lim) and concentration(s, w, lim_sugar):
                if c < s * 100 / (s + w):
                    c = s * 100 / (s + w)
                    ans = (s+w, s)
    print(*ans)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

water_g=[]
for i in range(f//100+1):
  for j in range(f//100+1):
#    print(i,j)
    w=100*a*i + 100*b*j
    if w<=f:
      water_g.append(w)
water_g=sorted(list(set(water_g)),reverse=True)

sugar_g=[]
for i in range(f*e//100):
  for j in range(f*e//100):
    s=c*i + d*j
    if s<=f:
      sugar_g.append(s)
sugar_g=sorted(list(set(sugar_g)),reverse=True)

#print(water_g, sugar_g)

ans_water=f
ans_sugar=0
for water in water_g:
  if water==0:
    break
  for sugar in sugar_g:
    if water+sugar<=f and sugar/water<=e/100:
      if sugar/(sugar+water)>ans_sugar/(ans_sugar+ans_water):
        ans_water=water
        ans_sugar=sugar
print(ans_water+ans_sugar,ans_sugar)

Submission status: Wrong Answer

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

water_g=[]
for i in range(f//100+1):
  for j in range(f//100+1):
#    print(i,j)
    w=100*a*i + 100*b*j
    if w<=f:
      water_g.append(w)
water_g=sorted(list(set(water_g)),reverse=True)

sugar_g=[]
for i in range(f//e+1):
  for j in range(f//e+1):
    s=c*i + d*j
    if s<=f:
      sugar_g.append(s)
sugar_g=sorted(list(set(sugar_g)),reverse=True)

#print(water_g, sugar_g)

ans_water=f
ans_sugar=0
for water in water_g:
  if water==0:
    break
  for sugar in sugar_g:
    if water+sugar<=f and sugar/water<=e/100:
      if sugar/(sugar+water)>ans_sugar/(ans_sugar+ans_water):
        ans_water=water
        ans_sugar=sugar
print(ans_water+ans_sugar,ans_sugar)

Submission status: Wrong Answer

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

water_g=[]
for i in range(f//100+1):
  for j in range(f//100+1):
#    print(i,j)
    w=100*a*i + 100*b*j
    if w<=f:
      water_g.append(w)
water_g=sorted(list(set(water_g)),reverse=True)

sugar_g=[]
for i in range(f//e):
  for j in range(f//e):
    s=c*i + d*j
    if s<=f:
      sugar_g.append(s)
sugar_g=sorted(list(set(sugar_g)),reverse=True)

#print(water_g, sugar_g)

ans_water=f
ans_sugar=0
for water in water_g:
  if water==0:
    break
  for sugar in sugar_g:
    if water+sugar<=f and sugar/water<=e/100:
      if sugar/(sugar+water)>ans_sugar/(ans_sugar+ans_water):
        ans_water=water
        ans_sugar=sugar
print(ans_water+ans_sugar,ans_sugar)

Submission status: Wrong Answer

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

water_g=[]
for i in range(f//100+1):
  for j in range(f//100+1):
#    print(i,j)
    w=100*a*i + 100*b*j
    if w<=f:
      water_g.append(w)
water_g=sorted(list(set(water_g)),reverse=True)

sugar_g=[]
for i in range(f+1):
  for j in range(f+1):
    s=c*i + d*j
    if s<=f:
      sugar_g.append(s)
sugar_g=sorted(list(set(sugar_g)),reverse=True)

#print(water_g, sugar_g)

ans_water=f
ans_sugar=0
for water in water_g:
  if water==0:
    break
  for sugar in sugar_g:
    if water+sugar<=f and sugar/water<=e/100:
      if sugar/(sugar+water)>ans_sugar/(ans_sugar+ans_water):
        ans_water=water
        ans_sugar=sugar
print(ans_water+ans_sugar,ans_sugar)

Submission status: Wrong Answer

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

water_g=[]
for i in range(f//100+1):
  for j in range(f//100+1):
#    print(i,j)
    w=100*a*i + 100*b*j
    if w<=f:
      water_g.append(w)
water_g=sorted(list(set(water_g)),reverse=True)

sugar_g=[]
for i in range(f+1):
  for j in range(f+1):
    s=c*i + d*j
    if s<=f:
      sugar_g.append(s)
sugar_g=sorted(list(set(sugar_g)),reverse=True)

#print(water_g, sugar_g)

ans_water=10000
ans_sugar=1
for water in water_g:
  if water==0:
    break
  for sugar in sugar_g:
    if water+sugar<=f and sugar/water<=e/100:
      if sugar/(sugar+water)>ans_sugar/(ans_sugar+ans_water):
        ans_water=water
        ans_sugar=sugar
print(ans_water+ans_sugar,ans_sugar)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = [0, 0, 0]
for a in range(2+F//A):
    for b in range(a+2):
        w = 100*A*a + 100*B*b
        if 0 < w < F:
            for c in range(2+(F-w)//C):
                for d in range(c+2):
                    s = C*c + D*d
                    if 0 < w + s <= F and s/w <= E/100:
                        if ans[2] < s/(w+s):
                            ans = [w+s,s,s/(w+s)]
print(*ans[:2])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
X = []
Y = []
res = 0
for i in range(f+1):
    for j in range(f+1):
        x = 100*a*i+100*b*j
        y = c*i+d*j
        if x > f and y > f:break
        X.append(x)
        Y.append(y)
def ok(x,y):
    return (x//100)*e >= y and x+y <=f
cnt = 0
X.sort()
Y.sort()
ansx = 100
ansy = 0
for x in X:
    for y in Y:
        if x+y > f:break
        
        if ok(x,y):
          
            if x+y == 0:continue
            if res < 100*y/(x+y):
                res = 100*y/(x+y)
                ansx = x
                ansy = y
        cnt +=1
print(ansx+ansy,ansy)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
X = []
Y = []
res = 0
for i in range(f+1):
    for j in range(f+1):
        x = 100*a*i+100*b*j
        y = c*i+d*j
        if x > f and y > f:break
        X.append(x)
        Y.append(y)
def ok(x,y):
    return (x//100)*e >= y and x+y <=f
cnt = 0
X.sort()
Y.sort()
ansx = 0
ansy = 0
for x in X:
    for y in Y:
        if x+y > f:break
        
        if ok(x,y):
          
            if x+y == 0:continue
            if res < 100*y/(x+y):
                res = 100*y/(x+y)
                ansx = x
                ansy = y
        cnt +=1
print(ansx+ansy,ansy)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
A, B, C, D, E, F = map(int, input().split())
s = set()
for i in range(31):
  for j in range(31):
    if (i * A + j * B) * 100 <= F:
      s.add((i * A + j * B) * 100)
    else: break
s.discard(0)
#print(s)
ss = set()
for i in range(3001):
  for j in range(3001):
    if i * C + (j * D) <= F:
      ss.add(i * C + j * D)
    else: break
resw = 100
ress = 0
for water in s:
  for suger in ss:
    if water // 100 * E >= suger and (water + suger <= F):
      if suger * (resw + ress) > (ress * (water + suger)):
        resw = water
        ress = suger
print(resw + ress, ress)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
A, B, C, D, E, F = map(int, input().split())
s = set()
for i in range(31):
  for j in range(31):
    if (i + j) * 100 <= F:
      s.add((i + j) * 100)
    else: break
s.discard(0)
#print(s)
ss = set()
for i in range(3001):
  for j in range(3001):
    if i * C + (j * D) <= F:
      ss.add(i * C + j * D)
    else: break
resw = 100
ress = 0
for water in s:
  for suger in ss:
    if water // 100 * E >= suger and (water + suger <= F):
      if suger / (water + suger) > (ress / (resw + ress)):
        resw = water
        ress = suger
print(resw + ress, ress)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=[]
for aa in range(31):
  for bb in range(31):
    w=100*(aa*a+bb*b)
    if w>f:break
    n=min(f-w,e*(aa*a+bb*b))
    for cc in range(3001):
      s=cc*c
      if s>n:break
      nn=n-s
      ss=d*(nn//d)
      ans.append([s+ss,w])
ans.sort(reverse=1)
s,w=ans[0]
print(w+s,s)

Submission status: Wrong Answer

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

ab_list = []
for a in range(F//100+1):
    for b in range(F//100+1):
        x = A*a + B*b
        if (0 < 100*x <= F) and (x not in ab_list):
            ab_list.append(x)

cd_list = []
for c in range(F+1):
    for d in range(F+1):
        y = C*c + D*d
        if (y <= F) and (y not in cd_list):
            cd_list.append(y)

max_conc = 0
result = [0, 0]
for i in ab_list:
    for j in cd_list:
        if (100*i + j <= F) and (j <= E*i):
            conc = (100*j) / (100*i + j)
            if conc > max_conc:
                max_conc = conc
                result = [100*i + j, j]

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

Submission status: Wrong Answer

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

ab_list = []
for a in range(F//100+1):
    for b in range(F//100+1):
        if 0 < 100*A*a + 100*B*b <= F:
            ab_list.append(A*a + B*b)

cd_list = []
for c in range(F+1):
    for d in range(F+1):
        if C*c + D*d <= F:
            cd_list.append(C*c + D*d)

max_conc = 0
result = [0, 0]
for i in ab_list:
    for j in cd_list:
        if (j <= E*i) and (100*i + j <= F):
            conc = 100*j / (100*i + j)
            if conc > max_conc:
                max_conc = conc
                result = [100*i + j, j]

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

Submission status: Wrong Answer

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

ab_list = []
for a in range(F//100):
    for b in range(F//100):
        if 0 < 100*A*a + 100*B*b <= F:
            ab_list.append(A*a + B*b)

cd_list = []
for c in range(F):
    for d in range(F):
        if C*c + D*d <= F:
            cd_list.append(C*c + D*d)

max_conc = 0
result = [0, 0]
for i in ab_list:
    for j in cd_list:
        if (j <= E*i) and (100*i + j <= F):
            conc = 100*j / (100*i + j)
            if conc > max_conc:
                max_conc = conc
                result = [100*i + j, j]

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

Submission status: Wrong Answer

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

max_sugar = E * (A + B)
ab_max = (F // 100*A) + 1
max_conc = 0

result = [0, 0]
for a in range(ab_max):
    for b in range(ab_max):
        sugar_max = E * (a + b)
        c = C * (sugar_max // C)
        d = D * ((sugar_max - c) // D)
        if (100*(a+b) > 0) and (100*(a+b) + c + d <= F):
            conc = 100*(c + d) / (100*(a + b) + c + d)
            if conc > max_conc:
                max_conc = conc
                result = [100*(a+b)+c+d, c+d]

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

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = 17, 19, 22, 26, 55, 2802

max_sugar = E * (A + B)
ab_max = (F // 100*A) + 1
max_conc = 0

result = [0, 0]
for a in range(ab_max):
    for b in range(ab_max):
        sugar_max = E * (a + b)
        c = C * (sugar_max // C)
        d = D * ((sugar_max - c) // D)
        if (100*(a+b) > 0) and (100*(a+b) + c + d <= F):
            conc = 100*(c + d) / (100*(a + b) + c + d)
            if conc > max_conc:
                max_conc = conc
                result = [100*(a+b)+c+d, c+d]

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

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
sug, dif2 = 0, 100
s = {}
wat1, wat2 = 100*a, 100*b
cap1, cap2 = a*e, b*e
for i in range(1,f//wat1+1):
    for j in range(f//wat2+1):
        if (wat1+cap1)*i+(wat2+cap2)*j<=f:
            s[cap1*i+cap2*j] = wat1*i+wat2*j
if s == {}:
    dif1 = f - wat1
    for i in range(10):
        for j in range(10):
            if 0<=(f-wat1) - (c*i+d*j)<dif1:
                dif1 = (f-wat1)-(c*i+d*j)
                sug3 = c*i+d*j
    print(wat1+sug3, sug3)
    exit(0)
for i in s.keys():
    for j in range(i//c+1):
        for k in range(i//d+1):
            if 0<=i-(c*j+d*k)<dif2:
                dif2 = i-(c*j+d*k)
                wat,sug1,sug2 = s[i],j,k
print(wat,sug1, sug2)
print(c*sug1+d*sug2+wat, c*sug1+d*sug2)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
sug, dif = 0, 100
s = {}
wat1, wat2 = 100*a, 100*b
cap1, cap2 = a*e, b*e
for i in range(1,f//wat1+1):
    for j in range(f//wat2+1):
        if (wat1+cap1)*i+(wat2+cap2)*j<=f:
            s[cap1*i+cap2*j] = wat1*i+wat2*j
if s == {}:
    print(wat1, 0)
    exit(0)
for i in s.keys():
    for j in range(i//c+1):
        for k in range(i//d+1):
            if 0<=i-(c*j+d*k)<dif:
                dif = i-(c*j+d*k)
                wat,sug1,sug2 = s[i],j,k
print(c*sug1+d*sug2+wat, c*sug1+d*sug2)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
sug, dif = 0, 100
s = {}
wat1, wat2 = 100*a, 100*b
cap1, cap2 = a*e, b*e
for i in range(1,f//wat1+1):
    for j in range(f//wat2+1):
        if (wat1+cap1)*i+(wat2+cap2)*j<=f:
            s[cap1*i+cap2*j] = wat1*i+wat2*j
if s == {}:
    print(wat1, 0)
    exit(0)
for i in s.keys():
    for j in range(i//c+1):
        for k in range(i//d+1):
            if 0<=i-(c*j+d*k)<dif:
                dif = i-(c*j+d*k)
                wat,sug1,sug2 = s[i],j,k
print(dif, sug1, sug2)
print(c*sug1+d*sug2+wat, c*sug1+d*sug2)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
sug = 0
wat = 100*a
cap = a*e
for i in range(100):
    for j in range(100):
        if (c*i+d*j<=cap) and (wat+c*i+d*j)<=f:
            sug = max(c*i+j*d, sug)
print(wat+sug, sug)