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: Runtime Error

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

val_max = 0
for a in range(1,1+F//(100*A)):
  for b in range(0,1+(F-100*A*a)//(100*B)):
    for c in range(0,1+(F-100*A*a-100*B*b)//C):
      for d in range(0,1+(F-100*A*a-100*B*b-C*c)//D):
        if C*c+D*d <= E*(A*a+B*b):
          val = (C*c+D*d)/(100*A*a+100*B*b+C*c+D*d)
          if val > val_max:
            val_max = val
            ans1 = 100*A*a+100*B*b+C*c+D*d
            ans2 = C*c+D*d
print(ans1,ans2)

Submission status: Runtime Error

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

water=[0]*3001
if 100*A<3001: water[100*A]=100*A
if 100*B<3001: water[100*B]=100*B
for i in range(3001):
  if water[i]>0:
    if i+100*A<3001: water[i+100*A]=i+100*A
    if i+100*B<3001: water[i+100*B]=i+100*B
for i in range(1,3001):
  if water[i]==0:
    water[i]=water[i-1]
#print(water)

suger=[0]*3001
suger[C]=C
suger[D]=D
for i in range(3001):
  if suger[i]>0:
    if i+C<3001: suger[i+C]=i+C
    if i+D<3001: suger[i+D]=i+D
for i in range(1,3001):
  if suger[i]==0:
    suger[i]=suger[i-1]
#print(suger)

tmp=0
for i in water:
  w=i
  s=suger[w//100*E]
  if w+s<=F and w+s>0:
    if s/(w+s)*100>tmp:
      tmp=s/(w+s)*100
      mw=w
      ms=s
print(mw+ms,ms)

Submission status: Runtime Error

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

water=[0]*3001
water[100*A]=100*A
water[100*B]=100*B
for i in range(3001):
  if water[i]>0:
    if i+100*A<3001: water[i+100*A]=i+100*A
    if i+100*B<3001: water[i+100*B]=i+100*B
for i in range(1,3001):
  if water[i]==0:
    water[i]=water[i-1]
#print(water)

suger=[0]*3001
suger[C]=C
suger[D]=D
for i in range(3001):
  if suger[i]>0:
    if i+C<3001: suger[i+C]=i+C
    if i+D<3001: suger[i+D]=i+D
for i in range(1,3001):
  if suger[i]==0:
    suger[i]=suger[i-1]
#print(suger)

tmp=0
for i in water:
  w=i
  s=suger[w//100*E]
  if w+s<=F and w+s>0:
    if s/(w+s)*100>tmp:
      tmp=s/(w+s)*100
      mw=w
      ms=s
print(mw+ms,ms)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from math import ceil, floor

def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    
    x = []
    y = []  

    for i in range(ceil(F/(100*A))+1):
        for j in range(ceil(F/(100*B))+1):
            dx = 100*A*i+100*B*j
            if(100*min(A,B) <= dx <= F):
                x.append(dx)

    for i in range(ceil(F/C)+1):
        for j in range(ceil(F/C)+1):
            dy = C*i+D*j
            if(0 <= dy <= F):
                y.append(dy)

    x = sorted(list(set(x)))
    y = sorted(list(set(y)))
    
    w = x[1]
    s = y[1]

    for i in x:
        for j in y:
            de = 100*s/(w+s)
            ne = 100*j/(i+j)
            if(i+j <= F and de < ne <= 100*E/(100+E)):
                # print(i, j, ne)
                w = i
                s = j

    print(w+s, s)

    return


# Generated by 1.1.5 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: Runtime Error

Solution code:
A, B, C, D, E, limit = map(int, input().rstrip("\n").split())

target_rate = E * 100 / (100 + E)
water_vars = {(i * A + j * B) * 100 for i in range(limit // (100 * A) + 1) for j in range(limit // (100 * B) + 1) if (i * A + j * B) * 100 <= limit}
water_vars = sorted(water_vars)
ans_solution = 0
ans_sugar = 0
min_rate_dest = 100

for water in water_vars:
    sugar_limit = limit - water
    sugar_vars = {i * C + j * D for i in range(sugar_limit // C + 1) for j in range(sugar_limit // D + 1) if i * C + j * D <= sugar_limit}
    sugar_vars = sorted(sugar_vars)
    for sugar in sugar_vars:
        rate = sugar * 100 / (sugar + water)
        if target_rate - rate == 0:
            ans_solution = water + sugar
            ans_sugar = sugar
            break
        elif 0 < target_rate - rate < min_rate_dest:
            ans_solution = water + sugar
            ans_sugar = sugar
            min_rate_dest = target_rate - rate
        else:
            break

print(ans_solution, ans_sugar)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_a = f // (100*a)
max_b = f // (100*b)
max_c = f // c
max_d = f // d
wat = []
sug = []
for i in range(max_a + 1):
    for j in range(max_b + 1):
        w = 100 * a * i + 100 * b * j
        if w <= f and w > 0:
            wat.append(w)
for i in range(max_c + 1):
    for j in range(max_d + 1):
        s = c*i + d*j
        if s < f:
            sug.append(s)
ans = 0
for x in wat:
    for y in sug:
        if x + y <= f and y <= e * x // 100:
            if ans < 100 * y // (x + y):
                ans =  100 * y // (x + y)
                out = [x+y, y]
print(*out)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_a = f // (100*a)
max_b = f // (100*b)
max_c = f // c
max_d = f // d
wat = []
sug = []
for i in range(max_a + 1):
    for j in range(max_b + 1):
        w = 100 * a * i + 100 * b * j
        if w =< f and w > 0:
            wat.append(w)
for i in range(max_c + 1):
    for j in range(max_d + 1):
        s = c*i + d*j
        if s < f:
            sug.append(s)
ans = 0
for x in wat:
    for y in sug:
        if x + y <= f and y <= e * x // 100:
            if ans < 100 * y // (x + y):
                ans =  100 * y // (x + y)
                out = [x+y, y]
print(*out)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
max_a = f // (100*a)
max_b = f // (100*b)
max_c = f // c
max_d = f // d
wat = []
sug = []
for i in range(max_a + 1):
    for j in range(max_b + 1):
        w = 100 * a * i + 100 * b * j
        if w < f and w > 0:
            wat.append(w)
for i in range(max_c + 1):
    for j in range(max_d + 1):
        s = c*i + d*j
        if s < f:
            sug.append(s)
ans = 0
for x in wat:
    for y in sug:
        if x + y <= f and y <= e * x // 100:
            if ans < 100 * y // (x + y):
                ans =  100 * y // (x + y)
                out = [x+y, y]
print(*out)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int,input().split())
dp = [0] * 31
ans = 0
MAX = 0
for i in range(1,31):
    dp[i] = max(i*E//C*C, i*E//D*D, i*E//(C+D)*(C+D))
for i in range(1,31):
    if 100*i+dp[i] <= F:
        result = (100*dp[i])/100*i+dp[i]
        if result > MAX:
            MAX = result
            ans = (100*i+dp[i], dp[i])
print(ans[0], ans[1])

Submission status: Runtime Error

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

maxconc = 0
for i in range(31):
    for j in range(31):
        water = A*i + B*j
        if 100 * water > F:continue
        loopk = E*water // C + 1
        loopl = E*water // D + 1
        
        for k in range(loopk):
            for l in range(loopl):
                sugar = C*k + D*l
                if 100*water + sugar > F or 100*water + sugar == 0:continue
                if sugar <= water * E:
                    conc = (sugar)/(sugar+100*water)
                    if conc > maxconc:
                        ans = [100*water+sugar,sugar]
                        maxconc = conc
                    
print(*ans)

Submission status: Runtime Error

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

maxconc = 0
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                water = A*i + B*j
                sugar = C*k + D*l
                if 100*water + sugar > F or 100*water + sugar == 0:continue
                if sugar <= water * E:
                    conc = (sugar)/(sugar+100*water)
                    if conc > maxconc:
                        ans = [100*water+sugar,sugar]
                        maxconc = conc
                    
print(*ans)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc074/tasks/arc083_a
# C - Sugar Water
import math
w_A, w_B, s_C, s_D, limit_E, max_F = list(map(int, input().split()))

# それ以上溶かすことができるか
# それ以上重量を増やせるか

# 取りうる水の組み合わせ
w_A_list = [w_A * x * 100 for x in range(math.floor(max_F / (w_A * 100)) + 1)]
w_B_list = [w_B * x * 100 for x in range(math.floor(max_F / (w_B * 100)) + 1)]

# 最悪で3000*3000
w_list = []
for a in w_A_list:
    for b in w_B_list:
        if a + b <= max_F:
            w_list.append(a + b)
w_list = list(set(w_list))  # 3000以下

# 取りうる水の組み合わせ
s_C_list = [s_C * x  for x in range(math.floor(max_F / s_C) + 1)]
s_D_list = [s_D * x  for x in range(math.floor(max_F / s_D) + 1)]

# 最悪で3000*3000
s_list = []
for c in s_C_list:
    for d in s_D_list:
        if c + d <= max_F:
            s_list.append(c + d)
s_list = list(set(s_list))  # 3000以下

max_d = 0
for w in w_list:
    for s in s_list:
        limit_s = w * limit_E / 100
        if w + s <= max_F and w + s != 0 and s <= limit_s:
            d = (s / (w + s)) * 100
            if d > max_d:
                max_d = d
                ans_ws, ans_s = w + s, s

ans = ' '.join([str(ans_ws), str(ans_s)])
print(ans)

Submission status: Runtime Error

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

a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
total = 100*A
ans_sugar = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = map(int,input().split())
a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
      max_dens = dens
      ans_total = total
      ans_sugar = j
            
print(ans_total, ans_sugar)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = map(int,input().split())
a_limit = int(-(-F//(100*A)))
b_limit = int(-(-F//(100*B)))
c_limit = int(-(-F*E//(100*C)))
d_limit = int(-(-F*E//(100*D)))

water_cand = []
for i in range(a_limit):
  for j in range(b_limit):
    water_cand.append(100*A*i+100*B*j)

water_cand = [x for x in list(set(water_cand)) if 0<x<F]

sugar_cand = []
for i in range(c_limit):
  for j in range(d_limit):
    sugar_cand.append(C*i + D*j)

sugar_cand = list(set(sugar_cand))

max_dens = 0
ans = 0
for i in water_cand:
  for j in sugar_cand:
    total = i + j
    dens = float(j)/total
    if total <= F and float(j)/i <= (E/100) and max_dens<dens:
            max_dens = dens
            ans_total = total
            ans_sugar = j
            
print(ans_total, ans_sugar)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
sato = set()
miz = set()
for i in range(F//100//A + 1):
	for j in range(F//100//B + 1):
		if i*A + j*B <= F//100:
			miz.add((i*A + j*B)*100)

for i in range(F//C + 1):
	for j in range(F//D + 1):
		if i*C + j*D <= F:
			sato.add(i*C + j*D)
miz = list(miz)
sato = list(sato)
#print(sorted(miz), sorted(sato))
node = 0
for i in range(len(miz)):
	if miz[i] == 0:
		continue
	for j in range(len(sato)):
		c = 100*sato[j]/miz[i]
		q = miz[i] + sato[j]
		if c > E:
			pass
		elif q > F:
			pass
		elif c > node:
			note = [miz[i] + sato[j], sato[j]]
			node = c

print(*note)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
sato = set()
miz = set()
for i in range(F//100//A + 1):
	for j in range(F//100//B + 1):
		if i*A + j*B <= F//100:
			miz.add((i*A + j*B)*100)

for i in range(F//C + 1):
	for j in range(F//D + 1):
		if i*C + j*D <= F:
			sato.add(i*C + j*D)
miz = list(miz)
sato = list(sato)
#print(sorted(miz), sorted(sato))
node = 0
for i in range(len(miz)):
	if i == 0:
		continue
	for j in range(len(sato)):
		c = 100*sato[j]/miz[i]
		q = miz[i] + sato[j]
		if c > E:
			pass
		elif q > F:
			pass
		elif c > node:
			note = [miz[i] + sato[j], sato[j]]
			node = c

print(*note)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
w=set()
s=set()
for i in range(31):
    for j in range(16):
        if 100*(A*i+B*j)<=F:
            w.add(100*(A*i+B*j))
for i in range(1501):
    for j in range(751):
        if C*i+D*j<=F/2:
            s.add(C*i+D*j)
w=list(w)
w.sort()
del w[0]
s=list(s)
s.sort()
M=-1
for i in w:
    for j in range(len(s)-1,-1,-1):
        t=s[j]/i
        if t*100<=E:
            if t>M and i+s[j]<=F:
                W,S=i,s[j]
                M=t
            break
print(W+S,S)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
w=set()
s=set()
for i in range(31):
    for j in range(16):
        if 100*(A*i+B*j)<=F:
            w.add(100*(A*i+B*j))
for i in range(1501):
    for j in range(751):
        if C*i+D*j<=F/2:
            s.add(C*i+D*j)
w=list(w)
w.sort()
del w[0]
s=list(s)
s.sort()
M=0
for i in w:
    for j in range(len(s)-1,-1,-1):
        t=s[j]/i
        if t*100<=E:
            if t>M and i+s[j]<=F:
                W,S=i,s[j]
                M=t
            break
print(W+S,S)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
w=set()
s=set()
for i in range(31):
    for j in range(16):
        if 100*(A*i+B*j)<=F:
            w.add(100*(A*i+B*j))
for i in range(1501):
    for j in range(751):
        if C*i+D*j<=F/2:
            s.add(C*i+D*j)
w=list(w)
del w[0]
s=list(s)
s.sort()
M=0
for i in w:
    for j in range(len(s)-1,-1,-1):
        t=s[j]/i
        if t*100<=E:
            if t>M and i+s[j]<=F:
                W,S=i,s[j]
                M=t
            break
print(W+S,S)

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
w=set()
s=set()
for i in range(31):
    for j in range(16):
        if 100*(A*i+B*j)<=F:
            w.add(100*(A*i+B*j))
for i in range(1501):
    for j in range(751):
        if C*i+D*j<=F/2:
            s.add(C*i+D*j)
w=list(w)
del w[0]
s=list(s)
s.sort()
a=0
M=0
for i in w:
    for j in range(len(s)-1,-1,-1):
        t=s[j]/i
        if t*100<=E and t>M and i+s[j]<=F:
            W,S=i,s[j]
            M=t
            break
print(W+S,S)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
a_list = set([])
b_list = set([])
for i in range((f // a) + 1):
    for j in range((f // b) + 1):
        if 0 < ((a*i) + (b*j)) * 100 <= f:
            a_list.add(((a*i)+(b*j))*100)
for i in range((f // c) + 1):
    for j in range((f // d) + 1):
        if ((c*i) + (d*j)) <= f:
            b_list.add((c*i)+(d*j))
ans = 0
ans_1 = 0
ans_2 = 0
for aa in a_list:
    for bb in b_list:
        if (aa + bb <= f) & ((bb / (aa + bb) * 100 <= e):
            if ans <= (bb / (aa + bb)) * 100:
                ans = (bb / aa) * 100
                ans_1 = aa + bb
                ans_2 = bb
print(str(ans_1) + " " + str(ans_2))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int A,B,C,D,E,F;
void dfs(int a, int b, int A, int B, vector<int> &w){
    if(a+b+A <= F){
        w.pb(a+b+A);
        dfs(a+A, b, A, B, w);
    }
    
    if(a+b+B <= F){
        w.pb(a+b+B);
        dfs(a, b+B, A, B, w);
    }
}

double calc(int w, int s){
    return 100 * s / double(w + s);
}

int main(void)
{
    cin >> A >> B >> C;
    cin >> D >> E >> F;
    vector<int> w;
    vector<int> s;

    A *= 100;
    B *= 100;

    dfs(0,0,A,B,w);
    dfs(0,0,C,B,s);

    SORT(w);
    SORT(s);

    w.erase(unique(ALL(w)), w.end());
    s.erase(unique(ALL(s)), s.end());

    int wa = 0;
    int sa = 0;
    double va = 0;
    double e = calc(100, E);
    for(auto&& wi : w){
        for(auto&& si : s){
            double v = calc(wi, si);
            if(v>e) continue;
            if(chmax(va, v)){
                wa = wi;
                sa = si;
            }
        }
    }
    pr(wa+sa, sa);
}

Submission status: Runtime Error

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 is None:print(0,0)
else:print(*ans)

Submission status: Runtime Error

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:return ans
        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
print(*solve())

Submission status: Runtime Error

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

amax = F//(100*A)
bmax = F//(100*B)
cmax = F//C
dmax = F//D
concmx =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: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
sugar = 0
s_water = 0
for a in range(F//(100*A)+1):
  for b in range((F-100*A*a)//(100*B)+1):
    f = F - 100*(a+b)
    max_s = min((a+b)*E, f)
    sugar_temp = 0
    s_water_temp = 0
    print(max_s)
    if max_s%C >= max_s%D:
      sugar_temp = max_s-max_s%D
    else:
      sugar_temp = max_s-max_s%C
    s_water_temp = 100*(a+b) + sugar_temp
    if sugar_temp/s_water_temp > sugar/s_water:
      sugar = sugar_temp
      s_water = s_water_temp
print(s_water, sugar)

Submission status: Runtime Error

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

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: Runtime Error

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: Runtime Error

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


'''
1.ビーカーに用意できる水の量のパターンを計算する
2.そこに砂糖を溶かせるだけ溶かす
3.全量がびーかの容量以下で濃度が100%以下であるものを採用する
'''

#1.作れる水の量をリストに入れる
#容量の入れもの　+100は余裕分
l = [0 for i in range(31)]
#aの作業で実現できる水
for i in range(0,len(l),a):
    l[i] = i*100
#bも使っていい場合
for i in range(1,len(l),b):
    #bだけで実現できる
    if (i/b).is_integer():
        l[i] = i*100
#aとbで実現できる
for i in range(a,len(l)-b,a):
    l[i] = i*100



suger = [0 for i in range(3001)]
#cの作業で実現できる砂糖
for i in range(0,len(suger),c):
    suger[i] = i
#dも使っていい場合
for i in range(1,len(suger)-d):
    #dだけで実現できる
    if i%d == 0:
        suger[i] = i
    #aとbで実現できる
    if suger[i] == i:
        suger[i+d] = (i+d)

#溶かせるだけ溶かして濃度比較
out_suger = 0
out_l = 0
conce = 0

for i in range(f//100+1):
    for j in reversed(range(3001)):
        #溶き切らない場合飛ばす
        if suger[j] > e*l[i]/100:
            continue
        #濃度が最大でand容量を超えていない
        elif conce < (suger[j]*100/(suger[j]+l[i])) and f >=(suger[j]+l[i]):
            conce = (suger[j]*100/(suger[j]+l[i]))            
            out_l = suger[j]+l[i]
            out_suger =suger[j]
            break

print(out_l,out_suger)
        


        
#print(l)
#print(suger)

Submission status: Runtime Error

Solution code:
cnt_A=0
cnt_B=0
cnt_C=0
cnt_D=0
max_noudo=0
water=0
sugar=0
while cnt_A*100*A <= F:
  cnt_B=0
  while cnt_B*100*B <= F-cnt_A*100*A:
    cnt_C=0
    while cnt_C*C <= F-cnt_A*100*A-cnt_B*100*B:
      cnt_D=0
      while cnt_D*D <= F-cnt_A*100*A-cnt_B*100*B-cnt_C*C:
        if (cnt_A*A+cnt_B*B)*E >= cnt_C*C+cnt_D*D >0:
          if max_noudo < 100*(cnt_C*C+cnt_D*D)/(cnt_A*A+cnt_B*B):
            max_noudo = 100*(cnt_C*C+cnt_D*D)/(cnt_A*A+cnt_B*B)
            water=cnt_A*A*100+cnt_B*B*100+cnt_C*C+cnt_D*D
            sugar=cnt_C*C+cnt_D*D
          cnt_D+=1
        else:
          break
      cnt_C+=1
    cnt_B+=1
  cnt_A+=1

print(str(water)+' '+str(sugar))

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = [int(i) for i in input().split()]
max_density = 0
#water = 0
#sugar = 0
for i_1 in range(f//(a*100)+1):
    for i_2 in range((f-100*a)//(b*100)+1):
        for i_3 in range(((i_1*a+i_2*b)*e)//c+1):
            i_4 = min((((i_1*a+i_2*b)*e)-i_3*c)//d , (f-(i_1*100*a+i_2*100*b+i_3*c))//d)
            if i_1 == 0 and i_2 == 0:
                break
            if (i_3*c + i_4*d)/(i_1*100*a+i_2*100*b+i_3*c + i_4*d) > max_density:
                max_density = (i_3*c + i_4*d)/(i_1*100*a+i_2*100*b+i_3*c + i_4*d)
                water = i_1*100*a+i_2*100*b
                sugar = i_3*c + i_4*d
print(water+sugar, sugar)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = [int(i) for i in input().split()]
max_density = 0
for i_1 in range(f//(a*100)+1):
    for i_2 in range((f-100*a)//(b*100)+1):
        for i_3 in range(((i_1*a+i_2*b)*e)//c+1):
            i_4 = (((i_1*a+i_2*b)*e)-i_3*c)//d
            if i_1 == 0 and i_2 == 0:
                break
            if i_1*100*a+i_2*100*b+i_3*c + i_4*d > f:
                continue
            if (i_3*c + i_4*d)/(i_1*100*a+i_2*100*b+i_3*c + i_4*d) > max_density:
                max_density = (i_3*c + i_4*d)/(i_1*100*a+i_2*100*b+i_3*c + i_4*d)
                water = i_1*100*a+i_2*100*b
                sugar = i_3*c + i_4*d
print(water+sugar, sugar)

Submission status: Runtime Error

Solution code:
import itertools

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

WF = F//100+1

water = [False] * (WF+1+30)
sugar = [False] * (F+1+30)

water[0] = True
sugar[0] = True

for n in range(WF):
  if water[n]:
    water[n+A] = True
    water[n+B] = True
for n in range(F):
  if sugar[n]:
    sugar[n+C] = True
    sugar[n+D] = True

water = set(100*x for x in range(1,1+WF) if water[x])
sugar = set(x for x in range(1,1+F) if sugar[x])

# at most 30 * 3000なので全てやる
ans_per = -1
for w, s in itertools.product(water, sugar):
  if w//100*E < s:
    continue
  if w+s > F:
    continue
  x = s/(w+s)
  if x > ans_per:
    ans_per = x
    ans_w = w
    ans_s = s

print(ans_w + ans_s, ans_s)

Submission status: Runtime Error

Solution code:
def main():
    A, B, C, D, E, F = map(int, input().split())
    xl = []
    yl = []
    for i in range(F):
        for j in range(F):
            x = 100 * A * i + 100 * B * j
            if F >= x and x not in xl:
                xl.append(x)
    for i in range(F):
        for j in range(F):
            y = C * i + D * j
            if F >= y and y not in yl:
                yl.append(y)
    ax = float('INF')
    ay = 0
    for x in xl:
        for y in yl:
            if F >= x + y and E / (E + 100) >= y / (x + y) and y / (x + y) > ay / (ax + ay):
                ax = x
                ay = y
    print(ax + ay, ay, end=' ')


main()

Submission status: Runtime Error

Solution code:
#C
A,B,C,D,E,F=map(int,input().split())
density=0
Ans1=0
Ans2=0
water=set() #setを使うと重複がなくなる
sugar=set()

bm=F//(100*B)
for i in range(bm+1):
    rw=F-100*i*B
    am=rw//(100*A)
    for j in range(am+1):
        water.add(100*i*B+100*j*A)

dm=F//D
for i in range(dm+1):
    rs=F-i*D
    cm=rs//C
    for j in range(cm+1):
        sugar.add(i*D+j*C)
sugar=sorted(sugar)
water=sorted(water)
for s in sugar:
    for w in water:
        if w/100*E<s:
            pass
        elif s+w>F or s+w==0:
            pass
        else
            den=s/(s+w)
            if den>density:
                density=den
                Ans1=s+w
                Ans2=s
            else:
                pass
print(Ans1,Ans2)

Submission status: Runtime Error

Solution code:
#C
A,B,C,D,E,F=map(int,input().split())
density=0
Ans1=0
Ans2=0
water=set() #setを使うと重複がなくなる
sugar=set()

bm=F//(100*B)
for i in range(bm+1):
    rw=F-100*i*B
    am=rw//(100*A)
    for j in range(am+1):
        water.add(100*i*B+100*j*A)

dm=F//D
for i in range(dm+1):
    rs=F-i*D
    cm=rs//C
    for j in range(cm+1):
        sugar.add(i*D+j*C)
sugar=sorted(sugar)
water=sorted(water)
for s in sugar:
    for w in water:
        if w/100*E<s:
            pass
        elif s+w>F or s+w=0:
            pass
        else
            den=s/(s+w)
            if den>density:
                density=den
                Ans1=s+w
                Ans2=s
            else:
                pass
print(Ans1,Ans2)