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

x = []
for i in range(0,F+1,A*100):
    for j in range(0,F+1,B*100):
        water = i + j
        if water > F:
            break
        x.append(water)

y = []
for i in range(0,F+1,C):
    for j in range(0,F+1,D):
        sugar = i + j
        if sugar > F:
            break
        y.append(sugar)

x = sorted(set(x))[1::]
y = sorted(set(y))

n = 0
WS = S = 0
for w in x:
    for s in y:
        if w + s > F:
            break
        if w * E//100 >= s:
            m = 100 * s / (w + s)
            if m > n:
                n = m
                WS, S = w + s , s

print(WS,S)

Submission status: Wrong Answer

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

x = sorted(set([w for i in range(0,F+1,A*100) for j in range(0,F+1,B*100) if (w := i + j) < F]))[1::]
y = sorted(set([s for i in range(0,F+1,C) for j in range(0,F+1,D) if (s := i + j) < F]))

n = 0
WS = S = 0
for w in x:
    for s in y:
        if w + s > F:
            break
        if w * E//100 >= s:
            m = s / (w + s)
        if m > n:
            n = m
            WS, S = w + s , s

print(WS,S)

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    a, b, c, d, e, f = ns()
    max_cncnt, ans_sum, ans_sugar = -1, 0, 0

    sugar_cand = []
    sugar_dp = [False for _ in range(f + 1)]
    sugar_dp[0] = True
    for i in range(f + 1):
        if sugar_dp[i]:
            if i + c <= f:
                sugar_dp[i + c] = True
            if i + d <= f:
                sugar_dp[i + d] = True
            sugar_cand.append(i)

    for i in range(f // (100 * a) + 1):
        for j in range(f // (100 * b) + 1):
            water = 100 * (a * i + b * j)
            if water == 0:
                continue
            if water > f:
                break
            sugar_lim = min(int(water * e / 100), f - water)
            sugar_idx = bisect.bisect_right(sugar_cand, sugar_lim)
            sugar = 0 if sugar_idx == 0 else sugar_cand[sugar_idx - 1]
            if max_cncnt < sugar / (water + sugar):
                ans_sum = water + sugar
                ans_sugar = sugar

    print(ans_sum, ans_sugar)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    a, b, c, d, e, f = ns()
    max_cncnt, ans_sum, ans_sugar = -1, 0, 0

    sugar_cand = []
    sugar_dp = [False for _ in range(f + 1)]
    sugar_dp[0] = True
    for i in range(f + 1):
        if sugar_dp[i]:
            if i + c <= f:
                sugar_dp[i + c] = True
            if i + d <= f:
                sugar_dp[i + d] = True
            sugar_cand.append(i)

    for i in range(f // (100 * a) + 1):
        for j in range(f // (100 * b) + 1):
            water = 100 * (a * i + b * j)
            if water == 0:
                continue
            if water > f:
                break
            sugar_lim = water * e // 100
            sugar_idx = bisect.bisect_right(sugar_cand, sugar_lim)
            sugar = 0 if sugar_idx == 0 else sugar_cand[sugar_idx - 1]
            if water + sugar <= f:
                if max_cncnt < sugar / (water + sugar):
                    ans_sum = water + sugar
                    ans_sugar = sugar

    print(ans_sum, ans_sugar)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    a, b, c, d, e, f = ns()
    max_cncnt, ans_sum, ans_sugar = -1, 0, 0

    sugar_cand = []
    sugar_dp = [False for _ in range(f + 1)]
    sugar_dp[0] = True
    for i in range(f + 1):
        if sugar_dp[i]:
            sugar_dp[min(f, i + c)] = True
            sugar_dp[min(f, i + d)] = True
            sugar_cand.append(i)

    for i in range(f // a + 1):
        for j in range(f // b + 1):
            water = 100 * (a * i + b * j)
            if water == 0:
                continue
            if water > f:
                break
            sugar_lim = water * e // 100
            sugar_idx = bisect.bisect_right(sugar_cand, sugar_lim)
            sugar = 0 if sugar_idx == 0 else sugar_cand[sugar_idx - 1]
            if water + sugar <= f:
                if max_cncnt < sugar / (water + sugar):
                    ans_sum = water + sugar
                    ans_sugar = sugar

    print(ans_sum, ans_sugar)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    a, b, c, d, e, f = ns()
    max_cncnt, ans_sum, ans_sugar = 0, 0, 0

    sugar_cand = []
    sugar_dp = [False for _ in range(f + 1)]
    sugar_dp[0] = True
    for i in range(f + 1):
        if sugar_dp[i]:
            sugar_dp[min(f, i + c)] = True
            sugar_dp[min(f, i + d)] = True
            sugar_cand.append(i)

    for i in range(f // a + 1):
        for j in range(f // b + 1):
            water = 100 * (a * i + b * j)
            if water == 0:
                continue
            if water > f:
                break
            sugar_lim = water * e // 100
            sugar_idx = bisect.bisect_right(sugar_cand, sugar_lim)
            sugar = 0 if sugar_idx == 0 else sugar_cand[sugar_idx - 1]
            if water + sugar <= f:
                if max_cncnt < sugar / (water + sugar):
                    ans_sum = water + sugar
                    ans_sugar = sugar

    print(ans_sum, ans_sugar)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
waters = []
for i in range(31):
    for j in range(31):
        v = 100*a*i + 100*b*j
        if v <= f and v != 0:
            waters.append(v)

waters = list(set(waters))
ans_vol, ans_sug = 100,0
for w in waters:
    rem = f - w
    max_s = e*w//100
    max_s = min(rem, max_s)
    for c_cnt in range(max_s//c+1):
        cs = c_cnt*c
        rem_d = max_s - cs
        d_cnt = rem_d//d
        ds = d_cnt*d
        sug = cs+ds
        vol = sug + w
        if ans_sug*vol < sug*ans_vol:
            ans_vol, ans_sug = vol, sug

print(ans_vol, ans_sug)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
waters = []
for i in range(31):
    for j in range(31):
        v = 100*a*i + 100*b*j
        if v <= f and v != 0:
            waters.append(v)

waters = list(set(waters))
ans_vol, ans_sug = 0,0
for w in waters:
    rem = f - w
    max_s = e*w//100
    max_s = min(rem, max_s)
    for c_cnt in range(max_s//c+1):
        cs = c_cnt*c
        rem_d = max_s - cs
        d_cnt = rem_d//d
        ds = d_cnt*d
        sug = cs+ds
        vol = sug + w
        if ans_sug*vol < sug*ans_vol:
            ans_vol, ans_sug = vol, sug

print(ans_vol, ans_sug)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
waters = []
for i in range(31):
    for j in range(31):
        v = 100*a*i + 100*b*j
        if v <= f and v != 0:
            waters.append(v)

waters = list(set(waters))
ans_vol, ans_sug = 0,0
curr_max = 0
for w in waters:
    rem = f - w
    max_s = e*w//100
    max_s = min(rem, max_s)
    for c_cnt in range(max_s//c+1):
        cs = c_cnt*c
        rem_d = max_s - cs
        d_cnt = rem_d//d
        ds = d_cnt*d
        s_sum = cs+ds
        vol = s_sum + w
        if curr_max < s_sum/vol:
            ans_vol, ans_sug = w+s_sum, s_sum
            curr_max = ans_sug/ans_vol

print(ans_vol, ans_sug)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

w = 0 # water
s = 0 # suger
maxdens = 0 # max density

def maxtrials(num, max, times=1):
  i = 0
  while i*num*times <= max:
    i+=1
  return i

maxA = maxtrials(A, F, 100)
maxB = maxtrials(B, F, 100)
maxC = maxtrials(C, E*max(A,B))
maxD = maxtrials(D, E*max(A,B))

for a in range(maxA):
  for b in range(maxB):
    for c in range(maxC):
      for d in range(maxD):
        if A*a*100 + B*b*100 + C*c + D*d <=F and A*a*100 + B*b*100 != 0:
            water = A*a*100 + B*b*100
            suger = C*c + D*d          
            dens = 100 * suger / (water + suger)
            if dens <= 100*E/(100+E) and maxdens <dens:              
              maxdens = dens
              w = water
              s = suger
    
print(str(w+s)+" "+str(s))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

w = 0 # water
s = 0 # suger
maxdens = 0 # max density

def maxtrials(num, max, times=1):
  i = 0
  while i*num*times <= max:
    i+=1
  return i

maxA = maxtrials(A, F, 100)
maxB = maxtrials(B, F, 100)
maxC = maxtrials(C, E*min(A,B))
maxD = maxtrials(D, E*min(A,B))

for a in range(maxA):
  for b in range(maxB):
    for c in range(maxC):
      for d in range(maxD):
        if A*a*100 + B*b*100 + C*c + D*d <=F and A*a*100 + B*b*100 != 0:
            water = A*a*100 + B*b*100
            suger = C*c + D*d          
            dens = 100 * suger / (water + suger)
            if dens <= 100*E/(100+E) and maxdens <dens:              
              maxdens = dens
              w = water
              s = suger
    
print(str(w+s)+" "+str(s))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

w = 0 # water
s = 0 # suger
maxdens = 0 # max density

def maxtrials(num, max, times=1):
  i = 0
  while i*num*times <= max:
    i+=1
  return i

maxA = maxtrials(A, F, 100)
maxB = maxtrials(B, F, 100)
maxC = maxtrials(C, min(100,F-(min(A,B)*100)))
maxD = maxtrials(D, min(100,F-(min(A,B)*100)))

for a in range(maxA):
  for b in range(maxB):
    for c in range(maxC):
      for d in range(maxD):
        if A*a*100 + B*b*100 + C*c + D*d <=F and A*a*100 + B*b*100 != 0:
            water = A*a*100 + B*b*100
            suger = C*c + D*d          
            dens = 100 * suger / (water + suger)
            if dens <= 100*E/(100+E) and maxdens <dens:              
              maxdens = dens
              w = water
              s = suger
    
print(str(w+s)+" "+str(s))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

w = 0 # water
s = 0 # suger
maxdens = 0 # max density

def maxtrials(num, max, times=1):
  i = 0
  while i*num*times <= max:
    i+=1
  return i

maxA = maxtrials(A, F, 100)
maxB = maxtrials(B, F, 100)
maxC = maxtrials(C, F-(min(A,B)*100))
maxD = maxtrials(D, F-(min(A,B)*100))

for a in range(maxA):
  for b in range(maxB):
    for c in range(maxC):
      for d in range(maxD):
        if A*a*100 + B*b*100 + C*c + D*d <=F:
          water = A*a*100 + B*b*100
          suger = C*c + D*d
          if water != 0:
            dens = 100 * suger / (water + suger)
            if dens <= 100*E/(100+E) and maxdens <dens:              
              maxdens = dens
              w = water
              s = suger
    
print(str(w+s)+" "+str(s))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

w = 0 # water
s = 0 # suger
maxdens = 0 # max density

def maxtrials(num, max, times=1):
  i = 0
  while i*num*times <= max:
    i+=1
  return i

maxA = maxtrials(A, F, 100)
maxB = maxtrials(B, F, 100)
maxC = maxtrials(C, F)
maxD = maxtrials(D, F)

for a in range(maxA):
  for b in range(maxB):
    for c in range(maxC):
      for d in range(maxD):
        if A*a*100 + B*b*100 + C*c + D*d <=F:
          water = A*a*100 + B*b*100
          suger = C*c + D*d
          if water != 0:
            dens = 100 * suger / (water + suger)
            if dens <= 100*E/(100+E) and maxdens <dens:              
              maxdens = dens
              w = water
              s = suger
    
print(str(w+s)+" "+str(s))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = input().split()
A = int(a)
B = int(b)
C = int(c)
D = int(d)
E = int(e)
F = int(f)

w = 0 # water
s = 0 # suger
maxdens = 0 # max density

def maxtrials(num, max, times=1):
  i = 0
  while i*num*times <= max:
    i+=1
  return i

maxA = maxtrials(A, F, 100)
maxB = maxtrials(B, F, 100)
maxC = maxtrials(C, F)
maxD = maxtrials(D, F)

for a in range(maxA):
  for b in range(maxB):
    for c in range(maxC):
      for d in range(maxD):
        if A*a*100 + B*b*100 + C*c + D*d <=F:
          water = A*a*100 + B*b*100
          suger = C*c + D*d
          if water != 0:
            dens = 100 * suger / (water + suger)
            if dens <= 100*E/(100+E) and maxdens <dens:              
              maxdens = dens
              w = water
              s = suger
    
print(str(w+s)+","+str(s))

Submission status: Wrong Answer

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

for i in range(F//(100*A)+1):
  for j in range(F//(100*B)+1):
    if 100*A*i + 100*B*j <= F:
      water += [100*A*i + 100*B*j]

water = list(set(water))

for i in range(F//C+1):
  for j in range(F//D+1):
    if C*i + D*j <= F:
      sugar += [C*i + D*j]

sugar = list(set(sugar))
sugar = sorted(sugar)

ans_sw = 0
ans_s = 0
ans = 0
for w in water:
  s = min((E/100)*w, F-w)
  idx = bisect.bisect_right(sugar, s)
  if w + sugar[idx-1] == 0:
    continue
  conc = (sugar[idx-1]/(w+sugar[idx-1]))*100
  if ans < conc:
    if sugar[idx-1] <= (E/100)*w:
      ans = conc
      ans_sw = w + sugar[idx-1]
      ans_s = sugar[idx-1]
print(ans_sw, ans_s)

Submission status: Wrong Answer

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

for i in range(F//(100*A)+1):
  for j in range(F//(100*B)+1):
    if 100*A*i + 100*B*j <= F:
      water += [100*A*i + 100*B*j]

water = list(set(water))

for i in range(F//C+1):
  for j in range(F//D+1):
    if C*i + D*j <= F:
      sugar += [C*i + D*j]

sugar = list(set(sugar))
sugar = sorted(sugar)
print(water, sugar)
ans_sw = 0
ans_s = 0
ans = 0
for w in water:
  s = min((E/100)*w, F-w)
  idx = bisect.bisect_right(sugar, s)
  if w == 110:
    print(s, idx, sugar[idx-1])
  if w + sugar[idx-1] == 0:
    continue
  conc = (sugar[idx-1]/(w+sugar[idx-1]))*100
  if ans < conc:
    if sugar[idx-1] <= (E/100)*w:
      ans = conc
      ans_sw = w + sugar[idx-1]
      ans_s = sugar[idx-1]
print(ans_sw, ans_s)

Submission status: Wrong Answer

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

for i in range(F//(100*A)+1):
  for j in range(F//(100*B)+1):
    if 100*A*i + 100*B*j <= F:
      water += [100*A*i + 100*B*j]

water = list(set(water))

for i in range(F//C):
  for j in range(F//D):
    if C*i + D*j <= F:
      sugar += [C*i + D*j]

sugar = list(set(sugar))
sugar = sorted(sugar)

ans_sw = 0
ans_s = 0
ans = 0
for w in water:
  s = min((E/100)*w, F-w)
  idx = bisect.bisect_right(sugar, s)
  if w == 110:
    print(s, idx, sugar[idx-1])
  if w + sugar[idx-1] == 0:
    continue
  conc = (sugar[idx-1]/(w+sugar[idx-1]))*100
  if ans < conc:
    if sugar[idx-1] <= (E/100)*w:
      ans = conc
      ans_sw = w + sugar[idx-1]
      ans_s = sugar[idx-1]
print(ans_sw, ans_s)

Submission status: Wrong Answer

Solution code:
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    """
    A, B, C, D, E, F = read_ints()
    dp = [False]*(F+1)
    dp[0] = True
    for i in range(F+1):
        if i+C < F+1:
            dp[i+C] = dp[i+C] or dp[i]
        if i+D < F+1:
            dp[i+D] = dp[i+D] or dp[i]
    # dp[i] - is True if i gram of sugar is obtainable
    # dp2[i] - highest gram of sugars that is lower than i
    dp2 = [0]*(F+1)
    highest_sugar = 0
    for i in range(1, F+1):
        if dp[i]:
            dp2[i] = highest_sugar = i
        else:
            dp2[i] = highest_sugar

    highest_ratio = [0, math.inf]

    for a in range(31):
        for b in range(31):
            water = 100*A*a+100*B*b
            if water < F:
                sugar_limit = min(E*water//100, F-water)
                sugar = dp2[sugar_limit]
                if sugar*highest_ratio[1] > water*highest_ratio[0]:
                    highest_ratio = [sugar, water]
    return sum(highest_ratio), highest_ratio[0]


if __name__ == '__main__':
    print(*solve())

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

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

A = A*100
B = B*100

Alim = 3000//A
Blim = 3000//B
water = []
for ai in range(Alim+1):
    for bi in range(Blim+1):
        tmp = ai*A+bi*B
        if tmp <=F:
            water.append(tmp)
water = set(water)

suger_limit = 3000
Clim = suger_limit//C
Dlim = suger_limit//D
suger = []
for ci in range(Clim+1):
    for di in range(Dlim+1):
        tmp = ci*C+di*D
        if tmp <=suger_limit:
            suger.append(tmp)
suger = sorted(list(set(suger)),reverse=1)

judge = 0
ans = [0,0]
limCon=100*E

while water:
    w = water.pop()
    for su in suger:
        
        if w+su > F:
            continue
        elif w+su == 0:
            continue
        else:
            con = 100*su/(w+su)
            
            if con>judge and con*(100+E)<=limCon:
                ans = [w+su,su]
                judge = con
                break

print(*ans)

Submission status: Wrong Answer

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

limit_water = f * 100 / (100 + e)
limit_suger = f * e / (100 + e)


waters = []
sugars = []

for i in range(31):
    for j in range(31):
        water = 100 * a * i + 100 * b * j
        if water != 0 and water <= 3000:
            waters.append(water)

for i in range(1500):
    for j in range(1500):
        sugar = c * i + d * j
        sugars.append(sugar)

ans = []
max_density = 0.0

sugars = list(set(sugars))
sugars.sort()
waters = list(set(waters))
waters.sort()

for water in waters:
    for sugar in sugars:
        if sugar + water <= f and sugar <= (water * e / 100):
            density = sugar / (sugar + water)
            if density > max_density:
                ans = [water + sugar, sugar]
                max_density = density

print(*ans)

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

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

A = A*100
B = B*100

Alim = 3000//A
Blim = 3000//B
water = []
for ai in range(Alim+1):
    for bi in range(Blim+1):
        tmp = ai*A+bi*B
        if tmp <=F:
            water.append(tmp)
water = set(water)

suger_limit = 3000
Clim = suger_limit//C
Dlim = suger_limit//D
suger = []
for ci in range(Clim+1):
    for di in range(Dlim+1):
        tmp = ci*C+di*D
        if tmp <=suger_limit:
            suger.append(tmp)
suger = sorted(list(set(suger)),reverse=1)

judge = 0
ans = [0,0]
limCon=100*E/(100+E)

while water:
    w = water.pop()
    for su in suger:
        
        if w+su > F:
            continue
        elif w+su == 0:
            continue
        else:
            con = 100*su/(w+su)
            
            if con>judge and con<=limCon:
                ans = [w+su,su]
                judge = con
                break

print(*ans)

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

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

A = A*100
B = B*100

Alim = 3000//A
Blim = 3000//B
water = []
for ai in range(Alim+1):
    for bi in range(Blim+1):
        tmp = ai*A+bi*B
        if tmp <=F:
            water.append(tmp)
water = set(water)

suger_limit = 30*E
Clim = suger_limit//C
Dlim = suger_limit//D
suger = []
for ci in range(Clim+1):
    for di in range(Dlim+1):
        tmp = ci*C+di*D
        if tmp <=suger_limit:
            suger.append(tmp)
suger = sorted(list(set(suger)),reverse=1)

judge = 0
ans = [0,0]
limCon=100*E/(100+E)

while water:
    w = water.pop()
    for su in suger:
        
        if w+su > F:
            continue
        elif w+su == 0:
            continue
        else:
            con = 100*su/(w+su)
            
            if con>judge and con<=limCon:
                ans = [w+su,su]
                judge = con
                break

print(*ans)

Submission status: Wrong Answer

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

limit_water = f * 100 / (100 + e)
limit_suger = f * e / (100 + e)


waters = []
sugars = []

for i in range(40):
    for j in range(40):
        water = 100 * a * i + 100 * b * j
        # if water != 0 and water <= limit_water:
        if water != 0 and (100 + e) * water <= f * 100:
            waters.append(water)

for i in range(4000):
    for j in range(4000):
        suger = c * i + d * j
        # if suger <= limit_suger:
        if suger * (100 + e) <= f * e:
            sugars.append(suger)

sugars.sort()
waters.sort()
ans = []
max_density = 0.0

for water in waters:
    for suger in sugars:
        if suger * (100 + e) <= e * (suger + water):
            density = suger / (suger + water)
            if density >= max_density:
                ans = [water + suger, suger]

print(*ans)

Submission status: Wrong Answer

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

limit_water = f * 100 / (100 + e)
limit_suger = f * e / (100 + e)


waters = []
sugars = []

for i in range(30):
    for j in range(30):
        water = 100 * a * i + 100 * b * j
        if water != 0 and water <= limit_water:
            waters.append(water)

for i in range(3000):
    for j in range(3000):
        suger = c * i + d * j
        if suger <= limit_suger:
            sugars.append(suger)

sugars.sort()
waters.sort()
ans = []
max_density = 0.0

for water in waters:
    for suger in sugars:
        if suger * (100 + e) <= e * (suger + water):
            density = suger / (suger + water)
            if density >= max_density:
                ans = [water + suger, suger]

print(*ans)

Submission status: Wrong Answer

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

concentration = 0
ans = [A,0]

water = []
for a in range(F//(A*100) + 1):
  for b in range(((F-a*A*100)//(B*100))+1):
    water.append((a*A+b*B)*100)
    
water = sorted(list(set(water)))

sugar = []
for c in range(F//C + 1):
  for d in range(((F - c*C)//D)+1):
    sugar.append(c*C+d*D)
sugar = sorted(list(set(sugar)))


for wa in water:
  for su in sugar:
    if wa + su <= F:
      if su <= (wa/100)*E:
        if wa != 0:
          if concentration < su/(su+wa):
            concentration = su/(su+wa)
            ans = [su+wa,su]

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

Submission status: Wrong Answer

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

concentration = 0
ans = [0,0]

water = []
for a in range(F//(A*100) + 1):
  for b in range(((F-a*A*100)//(B*100))+1):
    water.append((a*A+b*B)*100)
    
water = sorted(list(set(water)))

sugar = []
for c in range(F//C + 1):
  for d in range(((F - c*C)//D)+1):
    sugar.append(c*C+d*D)
sugar = sorted(list(set(sugar)))


for wa in water:
  for su in sugar:
    if wa + su <= F:
      if su <= (wa/100)*E:
        if wa != 0:
          if concentration < su/(su+wa):
            concentration = su/(su+wa)
            ans = [su+wa,su]

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

Submission status: Wrong Answer

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

concentration = 0
ans = [0,0]

water = []
for a in range(F//(A*100) + 1):
  for b in range(((F-a*A*100)//(B*100))+1):
    water.append((a*A+b*B)*100)
    
water = sorted(list(set(water)))

for i in range(len(water)):
  #print(water[i] //100 * E,F - water[i])
  limit = min(water[i] //100 * E,F - water[i])
  
  for c in range(limit//C + 1):
    sugar = c * C + ((limit - c * C)//D) * D
    if water[i] != 0:
      if concentration < sugar/water[i]+sugar:
        if F >= sugar + water[i]:
          concentration = sugar/water[i]+sugar
          #print(c,water[i] //100 * E,F - water[i],ans)
          ans = [water[i]+sugar,sugar]
        
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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

concentration = 0
ans = [0,0]

water = []
for a in range(F//(A*100) + 1):
  for b in range(((F-a*A*100)//(B*100))+1):
    water.append((a*A+b*B)*100)
    
water = sorted(list(set(water)))

for i in range(len(water)):
  limit = min(water[i] //100 * E,(F - water[i])//2)
  
  for c in range(limit//C + 1):
    sugar = c * C + ((limit - c * C)//D) * D
    if water[i] != 0:
      if concentration < sugar/water[i]+sugar:
        concentration = sugar/water[i]+sugar
        ans = [water[i]+sugar,sugar]
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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

concentration = 0
ans = [0,0]

water = []
for a in range(F//(A*100) + 1):
  for b in range(((F-a*A*100)//(B*100))+1):
    water.append((a*A+b*B)*100)
    
water = sorted(list(set(water)))

for i in range(len(water)):
  limit = min(water[i] //100 * E,F - water[i])
  
  for c in range(limit//C + 1):
    sugar = c * C + ((limit - c * C)//D) * D
    if water[i] != 0:
      if concentration < sugar/water[i]+sugar:
        concentration = sugar/water[i]+sugar
        ans = [water[i]+sugar,sugar]
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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

concentration = 0
ans = [0,0]

water = []
for a in range(F//(A*100) + 1):
  for b in range(((F-a*A*100)//(B*100))+1):
    water.append((a*A+b*B)*100)
    
water = sorted(list(set(water)))
print(water)

for i in range(len(water)):
  limit = min(water[i] //100 * E,F - water[i])
  
  for c in range(limit//C + 1):
    sugar = c * C + ((limit - c * C)//D) * D
    if water[i] != 0:
      if concentration < sugar/water[i]+sugar:
        concentration = sugar/water[i]+sugar
        ans = [water[i]+sugar,sugar]
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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

concentration = 0
ans = [0,0]

water = []
for a in range(F//(A*100) + 1):
  for b in range(((F-a*100)//(B*100))+1):
    water.append((a*A+b*B)*100)
    
water = sorted(list(set(water)))

for i in range(len(water)):
  limit = min(water[i] //100 * E,F - water[i])
  
  for c in range(limit//C + 1):
    sugar = c * C + ((limit - c * C)//D) * D
    if water[i] != 0:
      if concentration < sugar/water[i]+sugar:
        concentration = sugar/water[i]+sugar
        ans = [water[i]+sugar,sugar]
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
def solve():


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

    #memo
    list = {}

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


    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    w_sum = i * ope1 + j * ope2
                    s_sum = k * ope3 + l * ope4
                    if w_sum == 0:
                        break
                    if w_sum+s_sum > F:
                        break
                    else:
                        if w_sum/100 * E >= s_sum:
                            p_tmp = (s_sum / (w_sum + s_sum)) * 100
                            list[i, j, k, l] = p_tmp

    max_v = max(list.values())

    for k, v in list.items():
        if v == max_v:
            print(ope1*k[0] + ope2*k[1] + ope3*k[2] + ope4*k[3], ope3*k[2] + ope4*k[3])

if __name__ == "__main__":
    solve()