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:
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(31) for j in range(31)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

res = [100, -1]
for w in water:
    for s in sugar:
        if w + s <= F and s <= w * E // 100:
            if s / (w + s) > res[1] / res[0]:
                res = [w + s, s]

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

Submission status: Accepted

Solution code:
# 2019/08/07

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

max_a=f//100*a
max_b=f//100*b
min_ab=min(a,b)*100
max_c=(f-min_ab)//c
max_d=(f-min_ab)//d


def solve():
    cnt=0   
    ans=0   
    for i in range(max_a):
        if i*a>f:break
        for j in range(max_b):
            if i==j==0:continue
            if (i*a+j*b)*100>f:break

            for k in range(max_c):
                if (i*a+j*b)*100+k*c>f:break
                for l in range(max_d):
                    if k==l==0:continue
                    if (i*a+j*b)*100+k*c+l*d>f:break
                    w=(i*a+j*b)*100
                    s=k*c+l*d
                    D=s/w
                    if D>e/100:break
                    if cnt<D:
                        ans=(w+s,s)
                        cnt=D
                    if D==e/100:
                        return ans
    return ans
ans=solve()
if ans==0:
    print(min(a,b)*100,0)
else:print(*ans)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
F=f//100
E=e/(e+100)
ans=[100*a,0]
W={i+j for i in range(0,F+1,a) for j in range(0,F+1,b)}
W=sorted(W)[1:]
for k in W:
    w=100*k
    for i in range(0,f+1,c):
        for j in range(0,f+1,d):
            s=i+j
            n=s/(w+s)
            if w+s>f or n>E: break
            if ans[1]/ans[0]<n:ans=[w+s,s]
print(ans[0],ans[1])

Submission status: Accepted

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

    answer_sugarwater = -1
    answer_sugar = -1
    max_strength = -1

    for a in range(0,F//(100*A)+1):
        for b in range(0,(F-a*A)//(100*B)+1):
            water = 100*(a*A+b*B)
            for c in range(0, (F-water)//C+1):
                for d in range(0, (F-water-c*C)//D+1):
                    if water == 0:
                        continue
                    sugar = c*C+d*D
                    strength = 100 * sugar / (water + sugar)
                    # print(str(water) + ' ' + str(sugar) + ' ' + str(strength))
                    if max_strength < strength and water + sugar <= F and sugar <= water/100*E:
                        max_strength = strength
                        answer_sugarwater = water + sugar
                        answer_sugar = sugar
    print(str(answer_sugarwater) + ' ' + str(answer_sugar))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    L = []
    for i in range(31):
        for j in range(31):
            if 100*(A*i+B*j) <= F:
                L.append(100*(A*i+B*j))
    L.sort()

    S = []
    for i in range(101):
        for j in range(101):
            if C*i+D*j<=F:
                S.append(C*i+D*j)
    S.sort()

    mx = 0
    ans = (A*100, 0)
    for l in L:
        for s in S:
            if l != 0 or s != 0:
                if l+s<=F and l*E/100 >= s and s/(l+s) > mx:
                    mx = s/(l+s)
                    ans = (l+s, s)
    print(ans[0], ans[1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
a,b,c,d,e,f = list(map(int,input().split()))
#水の入れ方を列挙
total_water_set = set()
for hund_a in range(0, f+1, 100*a):
    total_water = hund_a
    while total_water <= f:
        total_water_set.add(total_water)
        total_water += 100*b

total_water_set.remove(0)
#砂糖の入れ方を列挙
total_sugar_set = set()
for _c in range(0, f+1, c):
    total_sugar = _c
    while total_sugar <= f:
        total_sugar_set.add(total_sugar)
        total_sugar += d

max_nodo = 0
max_sugawater_weight = min(total_water_set)
max_sugar_weight = 0
import decimal
total_water_set = list(map(decimal.Decimal,total_water_set))
total_sugar_set = list(map(decimal.Decimal,total_sugar_set))
nodo_limit = 100 * decimal.Decimal(e) / (100+decimal.Decimal(e))
for water in total_water_set:
    for sugar in total_sugar_set:
        if water + sugar <= f:
            nodo = 100 * sugar / (water + sugar)
            if nodo > max_nodo and nodo <= nodo_limit:
                max_nodo = nodo
                max_sugawater_weight = water + sugar
                max_sugar_weight = sugar
print("{} {}".format(max_sugawater_weight,max_sugar_weight))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int, C: int, D: int, E: int, F: int):

    mwater = 0
    msugar = 0
    mnoudo = 0

    # ope1
    for i in range(-(-F//100)*A+1):
        # ope2
        for j in range(-(-F//100)*B + 1):
            water = 100*A*i+100*B*j
            if water > F:
                break
            # ope3
            for k in range(-(-water*E//100)//C + 1):
                if water+C*k > F:
                    break
                for l in range(-(-water*E//100)//D + 1):
                    sugar = C*k + D*l
                    if water + sugar > F:
                        break
                    if (water*E/100) < sugar:
                        break
                    if water+sugar == 0:
                        break
                    noudo = 100*sugar/(water+sugar)
                    # print(water, sugar, noudo)
                    if mnoudo <= noudo:
                        mnoudo = noudo
                        mwater = water
                        msugar = sugar
    print(mwater+msugar, msugar)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    F = int(next(tokens))  # type: int
    solve(A, B, C, D, E, F)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

amax = F//(100*A)
bmax = F//(100*B)

concmx =0
wholemx =0
sugarmx =0

for a in range(amax,-1,-1):
    bmax = (F-100*A*a)//B
    for b in range(bmax,-1,-1):
        cmax = (F-100*A*a-100*B*b)//C
        
        for c in range(cmax,-1,-1):
            dmax = (F-100*A*a-100*B*b-C*c)//D
            for d in range(dmax,-1,-1):
                sugar =C*c+D*d
                whole = 100*A*a+100*B*b+sugar
                if whole ==0:
                    break
                elif sugar/whole <= E/(100+E) and whole <=F:
                    if sugar/whole >= concmx:
                        concmx =sugar/whole
                        sugarmx = sugar
                        wholemx =whole
                    
                   
print(str(wholemx)+" "+str(sugarmx))

Submission status: Accepted

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

amax = F//(100*A)
bmax = F//(100*B)

concmx =0
wholemx =0
sugarmx =0

for a in range(amax,-1,-1):
    for b in range(bmax,-1,-1):
        cmax = (F-100*A*a-100*B*b)//C
        dmax = (F-100*A*a-100*B*b)//D
        for c in range(cmax,-1,-1):
            for d in range(dmax,-1,-1):
                sugar =C*c+D*d
                whole = 100*A*a+100*B*b+sugar
                if whole ==0:
                    break
                elif sugar/whole <= E/(100+E) and whole <=F:
                    if sugar/whole >= concmx:
                        concmx =sugar/whole
                        sugarmx = sugar
                        wholemx =whole
                    
                   
print(str(wholemx)+" "+str(sugarmx))

Submission status: Accepted

Solution code:

import sys

def main():
    a, b, c, d, e, f = map(int, input().split())
    ans = [-1, 0, 0]
    for i in range(31):
        for j in range(31):
            now_water = i * 100 * a + j * 100 * b
            if now_water == 0:
                continue
            if now_water > f:
                break
            for k in range(10000):
                for l in range(100000):
                    now_sio = k * c + l * d
                    if now_sio > (i * a + j * b) * e:
                        break
                    if now_water + now_sio > f:
                        break
                    noud = 100 * now_sio / (now_water + now_sio)
                    # print(now_water, now_sio)
                    if noud > ans[0]:
                        ans[0] = noud
                        ans[1] = now_water + now_sio
                        ans[2] = now_sio

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



if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = -1
sugar = 0
sugar_water = 0
for a in range(F // (A * 100) + 1):
    for b in range((F - 100 * A * a) // (B * 100) + 1):
        for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
            for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                x = a * A + b * B
                y = c * C + d * D
                if x == 0:
                    continue
                if x * E >= y and ans < (100 * y)/(x*100+y):
                    ans = (100 * y)/(x*100+y)
                    sugar = y
                    sugar_water = 100 * x + y
print(sugar_water,sugar)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    A,B,C,D,E,F = inputMap()
    A = A*100
    B = B*100
    
    ans_muzu = 0
    ans_satou = 0
    ans = -1
    
    for i in range(0, F, A):
        for j in range(0, F, B):
            for ii in range(0, F, C):
                for jj in range(0, F, D):
                    
                    if F < i + j + ii + jj:
                        continue
                        
                    mizu = i+j
                    satou = ii+jj
                    
                    if mizu == 0:
                        continue
                    
                    if satou / mizu > E / 100:
                        continue
                    
                    tmp = (satou / (satou+mizu)) * 100
                    if ans < tmp:
                        ans = tmp
                        ans_muzu = mizu
                        ans_satou = satou
                        
    print("{} {}".format(ans_muzu+ans_satou, ans_satou))
    
    
    
            	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

A=sorted(list(set([a*i+b*j for j in range(f//(100*b)+1) for i in range(f//(100*a)+1) if 100*(a*i+b*j)<=f])))
B=sorted(list(set([c*i+d*j for j in range(f//d+1) for i in range(f//c+1) if c*i+d*j<=f])))

r=w=s=0
for x in A[1:]:
    for y in B:
        if 100*x+y<=f and y<=x*e and r<=y/(100*x+y):
            r=y/(100*x+y)
            w=100*x+y
            s=y
print(w,s)

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
M = 0
Sans = 0
Concmax = -1

for i in range(F//100//A+1):
  WA = i*100*A
  for k in range((F-WA)//100//B+1):
    WB = k*100*B
    W = WA+WB
    if W <= F:
      for j in range((F-W)//C+1):
        SC = j*C
        for l in range((F-W-C)//D+1):
          SD = l*D
          S = SC+SD
          if 0 < W+S <= F and S <= W*E/100:
            Conc = S/(S+W)
            if Conc > Concmax:
              Concmax= Conc
              Sans = S
              M = S+W
#              print(WA,WB,SC,SD,Conc)
print(M,Sans)

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
conc = 0
total = 0
sugar = 0
for i in range((f-100*a)//d + 1):
    for j in range((f-100*a-d*i)//c + 1):
        sugar_total = d*i + c*j
        conc_prep = sugar_total/(sugar_total+100*a)
        if sugar_total <= e*a and conc <= conc_prep:
            conc = conc_prep
            total = sugar_total + 100*a
            sugar = sugar_total

for i in range(1, f//(100*b)+1):
    diff = f - 100*b*i
    for j in range(diff//(100*a)+1):
        sugar_max = diff - 100*a*j
        for k in range(sugar_max//d + 1):
            for l in range((sugar_max - k*d)//c + 1):
                sugar_total = k*d + l*c
                total_prep = sugar_total + 100*(b*i + a*j)
                conc_prep = sugar_total/total_prep
                if sugar_total <= e*(b*i+a*j) and conc <= conc_prep:
                        conc = conc_prep
                        total = total_prep
                        sugar = sugar_total
print(total, sugar)

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
wans,sans,Cans=100*a,0,0
for p in range(1+(f//100*a)):
    for q in range(1+(f//100*b)):
        water=100*(a*p+b*q)
        if water>f or water==0:
            pass
        else:
            limit=(a*p+b*q)*e
            for r in range(1+(limit//c)):
                for s in range(1+(limit//d)):
                    suger=r*c+s*d
                    if water+suger>f or c*r+d*s>limit:
                        pass
                    else:
                        C=suger/(water+suger)
                        if C>=Cans:
                            wans,sans,Cans=water,suger,C
print(wans+sans,sans)

Submission status: Accepted

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

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

L.sort()


su = 0
for i, l in enumerate(L):
    limit = min(F-100*l, E*l)
    wd = 100*l
    if i == 0:
        w = wd
    for c in range(3000):
        if C*c >limit:
            break
        d = (limit - C*c) // D
        p = C*c+D*d
        if p*w > wd*su:
            w = wd
            su = p
print(w+su, su)

Submission status: Accepted

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

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

sugar = []
for i in range(C+1):
    for j in range(D+1):
        if C*i + D*j < F:
            sugar.append(C*i+D*j)
            
water.sort()
sugar.sort()
    
MAX = 0
MAXSUGAR = 0
MAXWEIGHT = 0
tmpsugar = 0
for i in range(len(water)):
    for j in range(len(sugar)):
        tmpsugar = sugar[j]
        while (water[i]+tmpsugar)<=F and tmpsugar <= water[i]*E//100:
            if MAX  <= 100*tmpsugar/(water[i]+tmpsugar):
                MAX  = 100*tmpsugar/(water[i]+tmpsugar)
                MAXSUGAR = tmpsugar
                MAXWEIGHT = water[i]+tmpsugar
            if tmpsugar == 0:
                break
            tmpsugar += sugar[j]

print(str(MAXWEIGHT)+" "+str(MAXSUGAR))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a = II(), II()
    print(n * n - a)
    return

#B
def B():
    _ = II()
    k = II()
    x = LI()
    ans = 0
    for xi in x:
        ans += min(xi, k - xi)
    print(ans * 2)
    return

#C
def C():
    a, b, c, d, e, F = LI()
    ans = [min(a,b)*100, 0]
    for ai in range(F // (100 * a) + 1):
        for bi in range((F - 100 * ai * a) // (100 * b) + 1):
            if ai == bi == 0:
                continue
            ab = ai * 100 * a + bi * 100 * b
            for ci in range((F - ab) // c + 1):
                for di in range((F - ab - ci * c) // d + 1):
                    if (ai * a + bi * b) * e < ci * c + di * d:
                        continue
                    if ans[1] / ans[0] < (ci * c + di * d) / (ab + ci * c + di * d):
                        ans = [ab + ci * c + di * d, ci * c + di * d]
    print(*ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
l_water=set()
for i in range(f//(a*100)+1):
    for j in range(f//(b*100)+1):
        tmp=i*a*100+j*b*100
        if 0<tmp<=f:l_water.add(tmp)
l_sugar=set()
max_s=max(l_water)//100*e
for i in range(max_s//c+1):
    for j in range(max_s//d+1):
        tmp=i*c+j*d
        if 0<=tmp<=max_s:l_sugar.add(tmp)
ans=[0,a*100,0]
for i in l_water:
    for j in l_sugar:
        if j<=i//100*e and i+j<=f:
            tmp=j/(i+j)
            if tmp>ans[0]:
                ans=[tmp,i+j,j]
print(*ans[1:])

Submission status: Accepted

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans = 0
W = set()
S = set()

for i in range(F):
  x1 = 100 * A * i
  if x1 > F:
    break
  for j in range(F):
    x2 = x1 + 100 * B * j
    if x2 > F or x2 == 0:
      break
    W.add(x2)
for i in range(F):
  y1 = C * i
  if y1 > F:
    break
  for j in range(F):
    y2 = y1 + D * j
    if y2 > F:
      break
    S.add(y2)

W = list(set(W))
S = list(set(S))

for i in range(len(W)):
  for j in range(len(S)):
    tmp = S[j]/W[i]
    tmp1 = S[j] + W[i]
    if tmp1 <= F and ans <= tmp <= E/100:
      ans = tmp
      ans1 = tmp1
      ans2 = S[j]
print(ans1, ans2)

Submission status: Accepted

Solution code:
import itertools
import math

LIM = 50



def do():
    ans = 0
    A,B,C,D,E,F= list(map(int,input().split(" ")))
    waters = []
    for i in range(31):
        for j in range(31):
            water = A*i* 100+B*j* 100
            if water <= F and water != 0:
                waters.append(water)
    solts = []
    for i in range(3000):
        for j in range(3000):
            solt = C * i + D * j
            if solt > E * F /100:
                break
            solts.append(solt)

    max_nodo = -1
    ans_water = 0
    ans_solt = 0
    for solt in solts:
        for water in waters:
            if solt/(water/100) <= E:
                if (100 * solt)/(solt+water) >= max_nodo and water + solt <= F:
                    max_nodo =(100 * solt)/(solt+water)
                    ans_water = water + solt
                    ans_solt = solt

    print(ans_water,ans_solt)





if __name__ == "__main__":
    do()

Submission status: Accepted

Solution code:
a,b,c,d,e,f=map(int,input().split())
dpw=[False]*31
dps=[False]*1501
dpw[0]=True
dps[0]=True
for i in range(1,31):
    if i>=a:
        dpw[i]=dpw[i] or dpw[i-a]
    if i>=b:
        dpw[i]=dpw[i] or dpw[i-b]
for i in range(1,1501):
    if i>=c:
        dps[i]=dps[i] or dps[i-c]
    if i>=d:
        dps[i]=dps[i] or dps[i-d]
Va=100*a
Vs=0
for i in range(1,31):
    for j in range(1501):
        if dpw[i] and dps[j]:
            Sum=100*i+j
            if Sum<=f and j<=i*e:
                if j/Sum>Vs/Va:
                    Va=Sum
                    Vs=j
print(Va,Vs)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC74 C

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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
water = [100*a*A + 100*b*B for B in range(t+1) for A in range(s+1) if 100*a*A + 100*b*B != 0]
suger = [c*C + d*D for D in range(v+1) for C in range(u+1)]
ans1 = 0
ans2 = 0
water = list(set(water))
suger = list(set(suger))
for W in water:
    for S in suger:
        if W + S <= f:
            if W*e >= 100*S:
                if concentration < S/(W+S):
                    concentration = S/(W+S)
                    ans1 = W+S
                    ans2 = S
if ans1 == 0:
    ans1 = 100*a
print(ans1,ans2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC74 C

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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
solution = 0
suger = 0
for A in range(s+1)[::-1]:
    for B in range(t+1)[::-1]:
        for C in range(u+1)[::-1]:
            for D in range(v+1)[::-1]:
                if 100*a*A + 100*b*B + c*C + d*D <= f:
                    if (a*A+b*B)*e >= (c*C + d*D):
                        if 100*a*A + 100*b*B + c*C + d*D != 0:
                            if concentration < (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D):
                                concentration = (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D)
                                solution = 100*a*A + 100*b*B + c*C + d*D
                                suger = c*C + d*D
if solution == 0:
    solution = 100*a
print(solution,suger)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC74 C

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

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
solution = 0
suger = 0
for A in range(s+1):
    for B in range(t+1):
        for C in range(u+1):
            for D in range(v+1):
                if 100*a*A + 100*b*B + c*C + d*D <= f:
                    if (a*A+b*B)*e >= (c*C + d*D):
                        if 100*a*A + 100*b*B + c*C + d*D != 0:
                            if concentration < (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D):
                                concentration = (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D)
                                solution = 100*a*A + 100*b*B + c*C + d*D
                                suger = c*C + d*D
if solution == 0:
    solution = 100*a
print(solution,suger)

Submission status: Accepted

Solution code:
a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100
w = set()
for i in range(f):
    _w = i * a
    if f < _w: break
    for j in range(f):
        __w = _w + j * b
        if f < __w: break
        w.add(__w)
w.remove(0)
s = set()
for i in range(f):
    _s = i * c
    if f < _s: break
    for j in range(f):
        __s = _s + j * d
        if f < __s: break
        s.add(__s)
m = -1
ans = (0, 0)
for _w in w:
    for _s in s:
        if 100 * _s <= e * _w and _w + _s <= f:
            t = 100 * _s / (_s+_w)
            if m < t:
                ans = (_w+_s, _s)
                m = t
print(*ans)

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int,input().split())
wl = set()
for ia in range(F//A+1):
    for ib in range(F//B+1):
        ww = ia*A*100+ib*B*100
        if 0 < ww <= F:wl.add(ww)

ws = set()
for ic in range((F*E)//(100*C) + 1):
    for idd in range((F*E)//(100*D)+1):
        ss = ic*C + idd*D
        if ss <= (F*E)/100:ws.add(ss)

g = 0
sw = sg = 0
for www in sorted(wl):
    ms = (www * E) // 100
    for c in sorted(ws):
        if c > ms:break
        else:
            if (c/www) <= E and (www+c) <=F:
                if g < c/(c+www):
                    g = c/(c+www)
                    sw = www
                    sg = c
if g == 0:
    print(100*A,0)
else:
    print(sg+sw,sg)

Submission status: Accepted

Solution code:
a,b,c,d,e,f = map(int,input().split())
mizu = []
satou = []
tmp_ans = []
ans = -1
ans_i = 0
ans_j = 0
for i in range(31):
    for j in range(31):
        tmp = a * 100 * i + b * 100 * j
        if tmp <= f:
            mizu.append(tmp)
mizu = list(set(mizu))
for i in range(101):
    for j in range(101):
        tmp = c * i + d * j
        if tmp <= f:
            satou.append(tmp)
satou = list(set(satou))
for i in mizu:
    for j in satou:
        if i + j <= f:
            if i + j != 0 and i != 0 and i // 100 * e >= j:
                if ans < j /(i + j):
                    ans = j / (i + j)
                    ans_i = i
                    ans_j = j
print(ans_i + ans_j,ans_j)

Submission status: Accepted

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

water = []
for i in range(32):
    if 100 * A * i > F:
        continue
    for j in range(32):
        if 100 * A * i + 100 * B * j > F:
            continue
        if i == 0 and j == 0:
            continue
        water.append(100 * A * i + 100 * B * j)

sugar = [0] * (F * F)
for i in range(F):
    if i * C > F:
        continue
    for j in range(F):
        if i * C + j * D > F:
            continue
        sugar.append(C * i + D * j)
sugar = list(set(sugar))

water.sort()
sugar.sort()
ans = 0
wa = 0
su = 0
for i in water:
    for j in sugar:
        if i + j <= F:
            if ans <= (100 * j / (i + j)) and (i / 100 * E) >= j:
                ans = (100 * j / (i + j))
                wa = i
                su = j

print(wa + su, su)

Submission status: Accepted

Solution code:
a ,b ,c ,d ,e ,f = map(int,input().split())
water = set()
sugar = set()
cou = 0
co = 0

for i in range(f//b):
    cou = 0
    while 100 * b * i + 100 * a * cou <= f:
        water.add(100 * b * i + 100 * a * cou)
        cou += 1
water = sorted(water)


for i in range(f//d):
    cow = 0
    while d * i + c * cow <= f:
        sugar.add(d * i + c * cow)
        cow += 1
sugar = sorted(sugar)




ans = [0,0,0]

for wat in water:
    for sug in sugar:
        if wat or sug:
            if wat + sug <= f and e / (100 + e) >= sug/(wat+sug):
                if ans[0] <= sug/(wat+sug):
                    ans = [sug/(wat+sug), wat+sug, sug]
print(ans[1],ans[2])

Submission status: Accepted

Solution code:
row = list(map(int, input().split()))
max_water= 0
max_sugar = 0
max_percent = 0

for w1 in range(int(row[5]/(row[0]*100))+1):
    for w2 in range(int((row[5]-w1*100*row[0])/(row[1]*100))+1):
        for s1 in range(int((row[5]-w1*100*row[0]-w2*row[1]*100)/row[2])+1):
            for s2 in range(int((row[5]-w1*100*row[0]-w2*row[1]*100-s1*row[2])/row[3])+1):
                water = w1*100*row[0]+w2*row[1]*100
                sugar = s1*row[2]+s2*row[3]
                if sugar + water != 0 and water != 0:
                    percent = 100*sugar/(water + sugar)
                    if max_percent < percent <= 100*row[4]/(100+row[4]):
                        max_water = water
                        max_sugar = sugar
                        max_percent = percent
if max_water == 0:
    if row[0]*100 <= row[5]:
        max_water = row[0]*100
    elif row[1]*100 <= row[5]:
        max_water = row[1]*100

print(max_water+max_sugar, max_sugar)

Submission status: Accepted

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

maxStrength = 0
ansMass = 0
ansSugar = 0
for i in range(0, F+1, 100*A):
        for j in range(0, F-i+1, 100*B):
                for k in range(0, F-i-j+1, C):
                        for l in range(0, F-i-j-k+1, D):
                                a = i + j
                                b = k + l
                                mass = a + b
                                if (a / 100)*E >= b and mass <= F and mass != 0:
                                        strength = (100*b) / mass
                                        if strength >= maxStrength:
                                                maxStrength = strength
                                                ansMass = mass
                                                ansSugar = b

print(ansMass, ansSugar)