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: Accepted

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a
# Cだけど水パフォ

import sys
read = sys.stdin.readline


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

# 水と砂糖の操作は独立にできる
# 知りたいのは砂糖の質量と水の質量
# 砂糖の質量の増加の仕方と水の質量の増加の仕方は全探索できる
# F<3000なので、1グラムずつ調べても10*7でpypyならギリok


from itertools import product
A, B, C, D, E, F = read_ints()

# 水の質量の増加の仕方
# Aの倍数とBの倍数はありえる #かつF[g]以下
candi_water = set()
for pa, pb in product(range(F // (A ** 100) + 2), range(F // (B ** 100) + 2)):
    candi = pa * A * 100 + pb * B * 100
    if candi > F:
        continue
    candi_water.add(candi)


# 砂糖の質量の増加の仕方
candi_suger = set()
for pa, pb in product(range(F // (C) + 2), range(F // (D) + 2)):
    candi = pa * C + pb * D
    if candi > F:
        continue
    candi_suger.add(candi)


# 全組み合わせを全探索
most = -1
ans = (-1, -1)
# print(candi_water, candi_suger)
for a, b in product(candi_water, candi_suger):
    if a == 0 or a + b > F or 100 * b > E * a:  # ビーカーに入らないか溶け残るか
        continue
    noudo = b / (a + b)
    if noudo > most:
        most = noudo
        ans = (a + b, b)
        # print(most, ans)
print(*ans)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
m_d = 0
m_t = 100*A
m_s = 0
for a in range(F//100*A+1):
  for b in range((F-100*A*a)//(100*B)+1):
    for c in range((F-A*a*100-B*b*100)//C+1):
      d = 0
      while (100*A*a+100*B*b) > 0 and 100*A*a+100*B*b+C*c+D*d <= F and (C*c+D*d)/(100*A*a+100*B*b) <= E/100:
        dens = (C*c+D*d)/(100*A*a+100*B*b)
        if dens == E/100:
          print(100*A*a+100*B*b+C*c+D*d,C*c+D*d)
          exit()
        elif m_d < dens:
          m_d = dens
          m_t = 100*A*a+100*B*b+C*c+D*d
          m_s = C*c+D*d
        d += 1
print(m_t,m_s)

Submission status: Accepted

Solution code:
# 100(aA + bB) + cC + dD <= F
# cC + dD <= (aA + bB)E
# maximize 100(cD + dD) / (100(aA + bB) + cC + dD)

A, B, C, D, E, F = map(int, input().split())
concentration = -1
ans = (0, 0)
for a in range(31):
    for b in range(31):
        water = 100*(a*A + b*B)
        if water > F:
            break
        for c in range(3001):
            for d in range(3001):
                sugar = c*C + d*D
                if water + sugar == 0:
                    continue
                if water + sugar > F:
                    break
                if sugar > water // 100 * E:
                    break
                conc = 100*sugar / (water + sugar)
                if concentration < conc:
                    concentration = conc
                    ans = (water + sugar, sugar)
print(ans[0], ans[1])

Submission status: Accepted

Solution code:
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 i == 0 and j == 0:
            continue
        w = A * 100 * i + B * 100 * j
        if w > F:
            continue
        water.append(w)
water = sorted(list(set(water)))

for k in range(F // C + 1):
    for l in range(F // D + 1):
        s = C * k + D * l
        if s > F:
            continue
        sugar.append(s)
sugar = sorted(list(set(sugar)))

ans_list = [100 * A, 0]  # 初期値の設定

for m in water:
    for n in sugar:
        total = m + n
        if total > F:  # ビーカーの上限
            continue
        c = 100 * n / (m + n)
        if c > E * 100 / (100 + E):  # 濃度の上限
            continue
        if c > ans_list[1] * 100 / sum(ans_list):  # できる限り高濃度
            ans_list = [m, n]  # リストの更新
print(sum(ans_list), ans_list[1])  # 砂糖水と砂糖の量を出力

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c,d,e,f=LI()
  ans=-inf
  ans_pair=[]
  lim=(100*e)/(100+e)
  for i in range(31):
    for j in range(31):
      for k in range(f//c+1):
        for l in range(f//d+1):
          mi=100*a*i+100*b*j
          sa=c*k+d*l
          s=mi+sa

          if s==0:
            continue

          if s>f:
            break

          noudo=(100*sa)/s
          if noudo>lim:
            break

          if ans<=noudo:
            ans=noudo
            ans_pair=[s,sa]

  return str(ans_pair[0])+' '+str(ans_pair[1])

# main()
print(main())

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A,B,C,D,E,F=MI()
    #dp[i][j]はi*100gのみずにjgの砂糖
    N=F//100+1
    dp=[[0]*(F+1) for _ in range(N)]
    
    dp[0][0]=1
    ansd=0
    ans=[100*A,0]
    
    AB=[A,B]
    CD=[C,D]
    
    for i in range(N):
        if dp[i][0]==1:
            for k in range(2):
                ii=i+AB[k]
                if ii<N:
                    dp[ii][0]=1
        for j in range(F+1):
            if dp[i][j]==1:
                for k in range(2):
                    jj=j+CD[k]
                    if jj<=F and i*100+jj<=F and jj<=E*i:
                        dp[i][jj]=1
                        d=jj/(100*i+jj)
                        if d>ansd:
                            ans=[100*i+jj,jj]
                            ansd=d
    print(' '.join(map(str, ans)))
    

    

main()

Submission status: Accepted

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

# 最初に水の入れ方の組み合わせを考える
water = []
for i in range(f//a+1):
    for j in range(f//b+1):
        if a*i + b*j <= f and not (i == 0 and j == 0):
            water.append(a*i + b*j)
water = list(set(water))
            
# 各組み合わせに対して砂糖を入れられる最大量
sugar = []
for w in water:
    sugar.append(min(f - w, (w//100)*e))
    
# 全探索
ans = [water[0], 0]
max_conc = 0
for w, s in zip(water, sugar):
    for i in range(s//c+1):  # 砂糖をc*i(g)入れる
        j = (s - c*i)//d  # d(g)入れられるだけ入れる
        cap = (c*i+d*j)  # 砂糖の量
        if (cap / (w + cap))*100 > max_conc:
            max_conc = (cap / (w + cap))*100
            ans = [w+cap, cap]
            
print(*ans)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int,input().split())
T = list(range(31))
ret = [100*A, 0]
for a in T:
  for b in T:
    SMax = min((A*a+B*b)*E,F-100*(A*a+B*b))
    for d in range(SMax//D+1):
      c = ( SMax - d*D ) // C
      S = C*c+D*d
      W = 100*(A*a+B*b) + S
      if (ret[1] * W) < (ret[0] * S):
        ret = [W,S]
print(*ret)

Submission status: Accepted

Solution code:
import math

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

ans = 0
ans1 = 0
ans2 = 0

for a in range(math.ceil(F / (A*100))+1):
  for b in range(math.ceil(F / (B*100))+1):
    for c in range(1000):
      for d in range(1000):
        if a == 0 and b == 0 and c == 0 and d == 0:
          continue
        
        if 100*A*a + 100*B*b + C*c + D*d > F:
          continue

        if (C*c)+(D*d) > E * (A*a+B*b):
          continue

        tmp = (C*c+D*d)*100 / (100*A*a + 100*B*b + C*c + D*d)
        if tmp > ans:
          ans = tmp
          ans1 = 100*A*a + 100*B*b + C*c + D*d
          ans2 = C*c + D*d

if ans2 == 0:
  print("{0} {1}".format(600, ans2))
else:
  print("{0} {1}".format(ans1, ans2))

Submission status: Accepted

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


rate = 0
water = 0
suger = 0

al = f // (a * 100)
bl = f // (b * 100)
for i in range(al + 1):
    for j in range(bl + 1):
        for k in range(100 + 1):
            for l in range(100 + 1):
                w = 100 * a * i + 100 * b * j
                s = c * k + d * l
                if w + s <= 0:
                    break
                temp = w + s
                r = (s * 100) / temp
                if temp <= f and (a * i + b * j) * e >= s:
                    if rate <= r:
                        water = w
                        suger = s 
                        rate = r
print(water + suger, suger)

Submission status: Accepted

Solution code:
A,B,C,D,E,F=map(int,input().split())
max_dencity=0
best_sugarwater=100*A
best_sugar=0

max_A=F//(A*100)
for a in range(max_A+1):
    max_B=(F-100*A*a)//(B*100)
    for b in range(max_B+1):
        water=A*a+B*b
        max_sugar=min(F-water*100,water*E)
        max_c=max_sugar//C
        for c in range(max_c+1):
            max_d=(max_sugar-C*c)//D
            for d in range(max_d+1):
                sugar=C*c+D*d
                sugarwater=water*100+sugar
                if sugarwater==0:
                    pass
                elif sugar/(sugarwater) > max_dencity:
                    max_dencity=sugar/(sugarwater)
                    best_sugarwater=sugarwater
                    best_sugar=sugar
                    
                
print(best_sugarwater,best_sugar)

Submission status: Accepted

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

water=set()
for a in range(0,F+1,100*A):
  for b in range(0,F+1,100*B):
    if a+b<=F: water.add(a+b)
water=sorted(list(water))

suger=set()
for c in range(0,F+1,C):
  for d in range(0,F+1,D):
    if c+d<=F: suger.add(c+d)
suger=sorted(list(suger))

ans,answater,anssuger=0,0,0
for w in water:
  for s in suger:
    if (w//100)*E<s or w+s>F: break
    if w+s!=0:
      if ans<=(100*s)/(w+s):
        answater,anssuger=w+s,s
        ans=(100*s)/(w+s)
print(answater,anssuger)

Submission status: Accepted

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

xy = []
# 水
for Ai in range(0,F+1,100*A):
    for Bj in range(0,F-Ai+1,100*B):
        # x <= F
        x = Ai + Bj

        # 塩
        for Ci in range(0,(F-x)+1,C):
            Dj = 0
            y = Ci + Dj
            while x + y <= F:
                xy.append((x,y))
                Dj += D
                y += D

ans = (100*A,0)
node = 0
for x,y in xy:
    if x == y == 0:
        continue
    # 完全に溶けるか
    if (x//100) * E >= y:
        tmp = 100*y/(x+y)
        # 濃度の最大をとる
        if node < tmp:
            ans = (x+y, y)
            node = tmp

print(*ans)

Submission status: Accepted

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

xy = []
for Ai in range(0,F+1,100*A):
    for Bj in range(0,F-Ai+1,100*B):
        x = Ai + Bj
        for Ci in range(0,(F-x)+1,C):
            Dj = 0
            y = Ci + Dj
            while x + y <= F:
                xy.append((x,y))
                Dj += D
                y += D

ans = (100*A,0)
node = 0
for x,y in xy:
    if x == y == 0:
        continue
    if (x//100) * E >= y:
        tmp = 100*y/(x+y)
        if node < tmp:
            ans = (x+y, y)
            node = tmp

print(*ans)

Submission status: Accepted

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

a = 0
b = 0
c = 0
for s in range(F//A+2):
    for t in range(F//B+2):
        tempa = 100*(s*A + t*B)
        if tempa >= F or tempa == 0:
            continue
        for u in range((F-tempa)//C+2):
            for v in range((F-tempa)//D+2):
                tempb = u*C+v*D
                if tempa+tempb > F:
                    continue
                if tempb/(tempa+tempb) > E/(100+E):
                    continue
                if c < tempb/(tempa+tempb):
                    a = tempa
                    b = tempb
                    c = tempb/(tempa+tempb)
if a+b == 0:
    a = 100*A
print(a+b, b)

Submission status: Accepted

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

A *= 100
B *= 100
dp = [-1]*(F+1)
if A <= F:
    dp[A] = 0
if B <= F:
    dp[B] = 0
for i in range(A, F + 1):
    if A <= i:
        dp[i] = max(dp[i - A], dp[i])
    if B <= i:
        dp[i] = max(dp[i - B], dp[i])
    if C <= i and dp[i-C] >= 0:
        if dp[i-C] + C <= (i-C - dp[i-C]) * (E / 100):
            dp[i] = max(dp[i-C] + C, dp[i])
    if D <= i and dp[i-D] >= 0:
        if dp[i-D] + D <= (i - D - dp[i-D]) * (E / 100):
            dp[i] = max(dp[i-D] + D, dp[i])


x = 0
id = 0
for i in range(A, F+1):
    if x <= (dp[i] / (i)):
        x = dp[i] / (i)
        id = i
print(id, dp[id])

Submission status: Accepted

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

# 水を入れる量の候補を決める
waterA = np.arange(31) * 100 * A
waterB = np.arange(31) * 100 * B
water = np.add.outer(waterA, waterB).flatten()
water = np.unique(water[water <= F])
water = water[np.nonzero(water)]

# 容器にあとどれだけ入れれるか
rest = F - water

# 溶ける砂糖の量
can_solve = np.minimum(water * E // 100, rest)

# 砂糖を入れる量の候補うんぬん
sugarC = np.arange(101) * C
sugarD = np.arange(101) * D
sugar = np.add.outer(sugarC, sugarD).flatten()
sugar = np.unique(sugar[sugar <= F])
sugar.sort()

pos = np.searchsorted(sugar, can_solve, side="right") - 1
ans = np.argmax(sugar[pos] / (water + sugar[pos]))
print(sugar[pos[ans]] + water[ans], sugar[pos[ans]])

Submission status: Accepted

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

water=set()
for a in range(0,F+1,100*A):
  for b in range(0,F+1,100*B):
    if a+b<=F: water.add(a+b)
water=sorted(list(water))
suger=set()
for c in range(0,F+1,C):
  for d in range(0,F+1,D):
    if c+d<=F: suger.add(c+d)
suger=sorted(list(suger))

kosa,ans1,ans2=0,0,0
for w in water:
  for s in suger:
    if (w//100)*E<s or w+s>F: break
    if w+s!=0 and kosa<=(100*s) / (w+s):
      kosa=(100*s) / (w+s)
      ans1,ans2=w+s,s
print(ans1,ans2)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

A, B, C, D, E, F = [int(x) for x in input().split()]

ans = [0, 0, -1]

for x in range((30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F or x + y == 0:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            b_2 = C * z + D * ((F - (a + C * z)) // D)
            if b + a > F or b > (a // 100) * E:
                b = 0
            if b_2 + a > F or b_2 > (a // 100) * E:
                b_2 = 0
            b = max(b, b_2)
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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

Submission status: Accepted

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

list_water = []
list_suger = []
max_conc = (100 * E) / (100 + E)
ans_conc = 0

for a in range(F // (100 * A) + 1) :
    for b in range(F // (100 * B) + 1) :
        if 100 * A * a + 100 * B * b <= F :
            water = 100 * A * a + 100 * B * b
            list_water.append(water)

for c in range(F // C + 1) :
    for d in range(F // D + 1) :
        if C * c + D * d <= F :
            suger = C * c + D * d
            list_suger.append(suger)

for i in list_water :
    for j in list_suger :
        if 0 < (i + j) <= F :
            concent = (100 * j) / (i + j)
            if ans_conc <= concent <= max_conc :
                ans_conc = concent
                ans = i + j
                ans_suger = j

print(ans, ans_suger)

Submission status: Accepted

Solution code:
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a,b,c,d,e,f = inm()
s = [False]*3001
for i in range(3001):
    for j in range(1501):
        k = c*i+d*j
        if k<=f:
            s[k] = True
w = [False]*32
for i in range(31):
    for j in range(16):
        k = a*i+b*j
        if 100*k<=f:
            w[k] = True
mx = 0.0
mxs = 0
mxsw = 100*a
for t in range(f-99):  # sugar gram
    if not s[t]:
        continue
    ww = t/e  # ww = ax+by must be this much
    for z in range(f//100 + 1, 0,-1):  # water/100
        if not w[z] or z*100+t>f:
            continue
        if z<ww:
            break
        r = t/(100*z+t)
        if r>mx:
            mx = r
            mxs = t
            mxsw = t+100*z
print("{} {}".format(mxsw,mxs))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    max_density = 0
    whole_weight = 0
    sugar_weight = 0
    A, B, C, D, E, F = map(int, input().split())
    for n_a in range(int(F / (100 * A)) + 1):
        for n_b in range(int((F - 100 * n_a * A) / (100 * B)) + 1):
            max_sugar = min(E * (n_a * A + n_b * B), F - 100 * (n_a * A + n_b * B))
            for n_c in range(int(max_sugar / C) + 1):
                for n_d in range(int((max_sugar - C * n_c) / D) + 1):
                    if 100 * (n_a * A + n_b * B) + n_c * C + n_d * D == 0:
                        continue
                    density = (n_c * C + n_d * D) / (100 * (n_a * A + n_b * B) + n_c * C + n_d * D)
                    if density > max_density or (density == 0 and max_density == 0):
                        max_density = density
                        whole_weight = 100 * (n_a * A + n_b * B) + n_c * C + n_d * D
                        sugar_weight = n_c * C + n_d * D

    print(whole_weight, sugar_weight)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

water_set=set()
for i in range( F // (A*100) + 1):
    for j in range( F // (B*100) + 1 ):
        volume_water = i*(A*100) + j*(B*100)
        
        if volume_water < F and volume_water != 0:
            water_set.add( volume_water )
        
water_list=sorted(water_set)
max_concent = -1
materials=[]
for w in water_list:
    max_sugar = (w // 100) * E

    sugar_set=set()
    for i in range( max_sugar // C + 1 ):
        for j in range( max_sugar // D + 1 ):
            volume_sugar = (i*C) + (j*D)
            
            if volume_sugar <= max_sugar and (w + volume_sugar) <= F:
                sugar_set.add( volume_sugar )
 
    sugar_list=sorted(sugar_set)
    for s in sugar_list:
        concent = s / (w + s) * 100
        if concent > max_concent:
            max_concent = concent
            materials = [w,s]
    
print( (materials[0] + materials[1]) , materials[1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math


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

water_set=set()
for i in range( F // (A*100) + 1):
    for j in range( F // (B*100) + 1 ):
        volume_water = i*(A*100) + j*(B*100)
        
        if volume_water < F and volume_water != 0:
            water_set.add( volume_water )
        
water_list=sorted(water_set)


max_concent = -1
materials=[]
for w in water_list:
    max_sugar = (w // 100) * E

    for i in range( max_sugar // C + 1 ):
        for j in range( max_sugar // D + 1 ):
            volume_sugar = (i*C) + (j*D)
            
            if volume_sugar <= max_sugar and (w + volume_sugar) <= F:
                concent = volume_sugar / (w + volume_sugar) * 100
                if concent > max_concent:
                    max_concent = concent
                    materials = [w,volume_sugar]
            
print( (materials[0] + materials[1]) , materials[1])

Submission status: Accepted

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

water=set()
for a in range(0,F+1,100*A):
  for b in range(0,F+1,100*B):
    if a+b<=F: water.add(a+b)
water=sorted(list(water))

suger=set()
for c in range(0,F+1,C):
  for d in range(0,F+1,D):
    if c+d<=F: suger.add(c+d)
suger=sorted(list(suger))

ans,answater,anssuger=0,0,0
for w in water:
  for s in suger:
    if (w//100)*E<s or w+s>F: break
    if w+s!=0:
      if ans<=(100*s)/(w+s):
        answater,anssuger=w+s,s
        ans=(100*s)/(w+s)
print(answater,anssuger)

Submission status: Accepted

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

density = 0
max_density = 0
ans = []
for a in range(31):
    if a*A*100> F:
        break
    for b in range(31):
        if a==0 and b==0:
            continue
        if a*A*100+b*B*100>F:
            break
        for c in range(101):
            for d in range(101):
                density = 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D)
#                 if c==0 and d==0 and max_density <= density:
#                     ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))
                if a*A*100+b*B*100*c*C+d*D>F:
                    break
#                 print(a*A*100 + b*B*100 + c*C + d*D)
                if ( a*A*100 + b*B*100 + c*C + d*D <= F ) and ( 100*(c*C+d*D)/(a*A*100 + b*B*100 + c*C + d*D) <= 100*E/(100+E) ):
#                     print(density)
#                     print("{} {}".format(a*A*100+b*B*100, c*C+d*D))
                    if max_density <= density:
#                         print(max_density)
                        max_density = density
                        ans.append("{} {}".format(a*A*100+b*B*100+c*C+d*D, c*C+d*D))


print(ans[-1])

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
water = []
sugar = []
pct = -1
ans_sugar = 0
ans_tot = 0

# water
for a in range(F + 1):
	if 100 * A * a > F: break
	for b in range(F + 1):
		x = 100 * A * a + 100 * B * b
		if x <= F:
			water.append(x)
			
# sugar
for a in range(F + 1):
	if C * a > F: break
	for b in range(F + 1):
		x = C * a + D * b
		if x <= F:
			sugar.append(x)
			
for w in water:
	for s in sugar:
		if w + s == 0: continue
		if w + s <= F and E * w / 100 >= s:
			if pct < s / (w + s):
				pct = s / (w + s)
				ans_sugar = s
				ans_tot = w + s
				
print(ans_tot, end = " ")
print(ans_sugar)

Submission status: Accepted

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

Submission status: Accepted

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

water1=a
water2=b
sugar1=c
sugar2=d

from functools import lru_cache
@lru_cache(maxsize=None)
def solve(w,s,nokori):
#    print("solve(",w,s,nokori,")")

    if nokori < 0:
        return [-1,w,s]

    max_s = w/100 * e

    if max_s >= s and w+s > 0:
        now = [100*s / (w+s),w,s]
    else:
        now=[-1,w,s]

    res1=solve(w+water1*100,s,nokori-water1*100)
    res2=solve(w+water2*100,s,nokori-water2*100)
    if max_s > s:
        res3=solve(w,s+sugar1,nokori-sugar1)
        res4=solve(w,s+sugar2,nokori-sugar2)
    else:
        res3=[-1,w,s]
        res4=[-1,w,s]

    lis = [now,res1,res2,res3,res4]
    lis.sort()

    return lis[-1]

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

Submission status: Accepted

Solution code:
# 総当たり：
# A, Bは30以下。30より大きいと重量の制約を満たせないから。
# 砂糖が溶け残らずに入る最大量は、E = 100, F = 3000 のときで、1500g. なので
# Dを総当たり（1500/2 = 750以下）してCを最大値決め打ち
# 30 * 30 * 750 = 750000 でいけるだろ。

a, b, c, d, e, f = list(map(int, input().split()))
ans_water = 1
ans_sugar = 0

for i_a in range(30+1):
    for i_b in range(15+1):
        water = 100 * a * i_a + 100 * b * i_b
        if water == 0:
            continue
        if water > f:
            continue
        for i_d in range(750+1):
            sugar = d * i_d
            if water + sugar > f:
                continue
            if sugar > water // 100 * e:
                continue
            sugar_max = water // 100 * e
            sugar_max = min(sugar_max, f - water)
            i_c = (sugar_max - sugar) // c

            # print(water, sugar, i_a, i_b, i_d, sugar_max, i_c)
            # if sugar + c * i_c == sugar_max:
            #     sugar += c * i_c
            #     print("{} {}".format(water + sugar, sugar))
            #     print("###")
            #     exit()
            
            sugar += i_c * c

            if sugar / water >= ans_sugar / ans_water:
                ans_sugar = sugar
                ans_water = water
                # print("koushin: ")
                # print(water, sugar, i_a, i_b, i_d, sugar_max, i_c)

print("{} {}".format(ans_water + ans_sugar, ans_sugar))

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

    dp = [[False] * (f+1) for _ in range(f+1)]
    dp[0][0] = True
    for i in range(f+1):
        for j in range(f+1):
            if dp[i][j]:
                if i + 100*a <= f:
                    dp[i+100*a][j] = True
                    if i + 100*b <= f:
                        dp[i+100*b][j] = True
                if j + c <= f and i+c <= f:
                    if ((i - j) / 100) * e >= (j+c):
                        dp[i+c][j+c] = True
                        if j + d <= f and i+d <= f:
                            if ((i - j) / 100) * e >= (j+d):
                                dp[i+d][j+d] = True

    M = 0
    sugar = 0
    con = -1
    for i in range(1, f+1):
        for j in range(f, -1, -1):
            if dp[i][j]:
                if j / i > con:
                    M = i
                    sugar = j
                    con = j/i
                break
    print(M, sugar)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A, B, C, D, E, F = [int(x) for x in input().split()]
a_water = 0
a_sugar = 0
a_conc = 0
max_conc = 100 * E / (100 + E)
for i in range(F//(100*A) + 1):
    for j in range((F-i*100*A)//(100*B) + 1):
        water = i * 100 * A + j * 100 * B
        if water == 0:
            continue
        for k in range((F-water)//C + 1):
            for l in range((F-water-C*k)//D + 1):
                sugar = k * C + l * D
                conc = 100 * sugar / (water + sugar) if water + sugar > 0 else 0
                if water + sugar <= F and conc <= max_conc and a_conc <= conc:
                    a_water = water
                    a_sugar = sugar
                    a_conc = conc
                else:
                    pass
print(a_water + a_sugar, a_sugar)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
maxDensity = 0
ans_water = A * 100
ans_sugar = 0

for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        water = (i * A + j * B) * 100
        rest = F - water
        if water > F:
            continue
        for k in range(rest // C + 1):
            for l in range(rest // D + 1):
                sugar = k * C + l * D
                if water + sugar > F:
                    continue
                if sugar * 100 > water * E:
                    continue
                if sugar + water == 0:
                    density = 0
                else:
                    density = sugar / (sugar + water)
                if maxDensity < density:
                    ans_water = water
                    ans_sugar = sugar
                    maxDensity = density


print(ans_water + ans_sugar, ans_sugar)

Submission status: Accepted

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

ans_omosa = 0
ans_sugar = 0
per_checker = 0

for _a in range(f // (a * 100)+1):
    for _b in range(f // (b * 100)+1):
        for _c in range((f // c)+1):
            for _d in range((f // d)+1):
                # 砂糖溶かしすぎチェック
                if (_c * c + _d * d) > (_a * a + _b * b) * e:
                    break
                # 重さチェック
                elif (_c * c + _d * d) + (_a * a + _b * b) * 100 > f:
                    break
                elif (_a * a * 100 + _b * b * 100 + _c * c + _d * d) == 0:
                    break
                else:
                    if per_checker < (_c * c + _d * d) / (_a * a * 100 + _b * b * 100 + _c * c + _d * d):
                        per_checker = (_c * c + _d * d) / (_a * a * 100 + _b * b * 100 + _c * c + _d * d)
                        ans_omosa = (_c * c + _d * d) + (_a * a + _b * b) * 100
                        ans_sugar = (_c * c + _d * d)
                        #print(_a, a, _b, b, _c, c, _d, d)

print("{} {}".format(max(a*100,ans_omosa), ans_sugar))

Submission status: Accepted

Solution code:
def rec_water(total):
    if total > F:
        return
    else:
        water_amount.append(total)
        rec_water(total+100*A)
        rec_water(total+100*B)


# def rec_sugar(total):
#     if total > 1500:
#         return
#     else:
#         sugar_amount.append(total)
#         rec_sugar(total+C)
#         rec_sugar(total+D)


water_amount = []
sugar_amount = []
A, B, C, D, E, F = map(int, input().split())
rec_water(0)
for i in range(1501):
    for j in range(1501):
        sugar_amount.append(i*C+D*j)

water_amount = list(set(water_amount))
sugar_amount = list(set(sugar_amount))
water_amount.remove(0)

ans_sugar_water = min(water_amount)
ans_sugar = 0
percent = 0

# 1つ目は求める砂糖水の質量, 2つ目はそれに溶けている砂糖の質量
for w in water_amount:
    for s in sugar_amount:
        if w+s > F or s > E*(w/100):
            continue
        else:
            # 濃度が高ければ更新する
            if s / (w+s) > percent:
                ans_sugar_water = w+s
                ans_sugar = s
                percent = s / (w+s)
print(ans_sugar_water, ans_sugar)