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:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().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')

#solve
def solve():
    a, b, c, d, e, f = LI()
    lis = []
    for i in range(f //c + 1):
        for k in range(f // d + 1):
            lis.append(c * i + d * k)
    lis = list(set(lis))
    lis.sort()
    ans = [100 * a, 0]
    for i in range(f // 100 + 1):
        for k in range(f // 100 + 1):
            if i == k == 0:
                continue
            water = a * i + b * k
           	if water * 100 > f:
              continue
            if water * e <= f - water * 100:
                aa = bisect_right(lis, water * e) - 1
                if aa == -1:
                    continue
                aa = lis[aa]
                if ans[1] / ans[0] < aa / (water * 100 + aa):
                    ans = [water * 100 + aa, aa]
    print(*ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().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')

#solve
def solve():
    a, b, c, d, e, f = LI()
    lis = []
    for i in range(f //c + 1):
        for k in range(f // c + 1):
            lis.append(c * i + d * k)
    lis = list(set(lis))
    lis.sort()
    ans = [100 * a, 0]
    for i in range(f // 100 + 1):
        for k in range(f // 100 + 1):
            water = (a * i + b * k)
            if water * e <= f - water * 100:
                aa = bisect_right(lis, water * e) - 1
                if aa == -1:
                    continue
                aa = lis[aa]
                if ans[1] / ans[0] < aa / (water * 100 + aa):
                    ans = [water * 100 + aa, aa]
    print(*ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

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

ans = []
max_conc = 0
for a in range(F // 100 + 1):
    left = F - 100 * a * A
    for b in range(left // 100 + 1):
        w = 100 * a * A + 100 * b * B

        s_max = min(F - w, w * E // 100)
        if s_max >= 0:
            for c in range(s_max // C + 1):
                d = (s_max - c * C) // D

                if d >= 0:
                    # suger
                    s = c * C + d * D
                    if s + w > 0:
                        conc = s / (s + w)
                        if conc > max_conc:
                            ans = [s, w]
                            max_conc = conc


print(str(ans[0] + ans[1]) + ' ' + str(ans[0]))

Submission status: Runtime Error

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

ans = []
max_conc = 0
for a in range(F // 100 + 1):
    for b in range(F // 100 + 1):
        w = 100 * a * A + 100 * b * B

        s_max = min(F - w, w * E // 100)
        if s_max >= 0:
            for c in range(s_max // C + 1):
                d_max = (s_max - c * C) // D

                if d_max >= 0:
                    # suger
                    s = c * C + d_max * D
                    if s + w > 0:
                        conc = s / (s + w)
                        if conc > max_conc:
                            ans = [s, w]

print(str(ans[0] + ans[1]) + ' ' + str(ans[0]))

Submission status: Runtime Error

Solution code:
import math

A,B,X = map(int,input().split())

# A * N + B * d(N) yen 

check_num = [1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000]

if((A*1+B*1)>X):
    print(0)
else:
    flag = True
    for i in range(len(check_num)):
        if((A*check_num[i]+B*(i+1)) > X):
            flag = False
            i=i-1
            break
    if(flag):
        print(10**9)
    else:
        value = math.ceil((X - B*(i))/A)
        print(value-1)

Submission status: Runtime Error

Solution code:
#074c
A,B,C,D,E,F = map(int, input().split())
    
#あり得る水量をすべて書き出す
set_water = set()

for i in range(F//(100*A),-1,-1):
    for j in range((F-(100*A*i))//(100*B),-1,-1):
        water = 100*A*i + 100*B*j
        if water not in set_water:
            set_water.add(water)

#print(set_water)

set_water_and_sugar = set()

#def get_conc(water,sugar,E,F):
#    if water/100*E < sugar or water+sugar == 0: #water + sugar > F or  …すでに制約済み
#        return 0
#    else:
#        return (100*sugar)/(water+sugar)

#あり得る水量に対して、ありえる砂糖の量をすべて書き出す (溶け残りの制約があるのでMAXのみではNG)
#for water in set_water:
#    for i in range((F-water)//C,-1,-1):
#        for j in range((F-water-C*i)//D,-1,-1):
#            sugar = C*i + D*j
#            if tuple([water,sugar]) not in set_water_and_sugar:
#                set_water_and_sugar.add(tuple([water,sugar]))              

#あり得る水量に対して、砂糖を限界量(重量制限or溶け残り制限)まで入れる
for water in set_water:
    for i in range((F-water)//C,-1,-1):
        j = min((water/100*E - C*i)//D , (F - water - C*i)//D)
        sugar = C*i + D*j
        if tuple([water,sugar]) not in set_water_and_sugar and sugar >= 0:
            #print(water,sugar,water+sugar,water/100*E)
            set_water_and_sugar.add(tuple([water,sugar]))
            
#最大濃度を求める
limit_conc = (100*E)/(100+E)
max_conc = 0
max_water_and_sugar = [0,0]

for water_and_sugar in set_water_and_sugar:
    water = water_and_sugar[0]
    sugar = water_and_sugar[1]
    conc = get_conc(water,sugar,E,F)
    
    #print(water,sugar,conc)
    
    if max_conc < conc:
        max_conc = conc
        max_water_and_sugar = [water,sugar]
        
        #最高濃度に達したら抜ける
        if max_conc == limit_conc:
            break
        
print(int(sum(max_water_and_sugar)),int(max_water_and_sugar[1]))

Submission status: Runtime Error

Solution code:
import math
a, b, c, d, e, f = [int(x) for x in input().split()]
threshold = e / (100 + e) * 100
max_concent = 0
max_total = 0
max_suger = 0
max_suger_try = int(threshold/100*f//c)
for i in range(31):
    for j in range(31):
        for k in range(max_suger_try):
            for l in range(max_suger_try):
                water = a * i * 100 + b * j * 100
                suger = c * k + d * l   
                if water == 0:
                    break
                concentration = suger / (water + suger) * 100
                if (water + suger > f or concentration > threshold) :
                    break
                else:
                    if concentration > max_concent:
                        max_concent = concentration
                        max_total = water + suger
                        max_suger = suger
if max_total = 0:
    max_total = a * 100
print("{} {}".format(max_total, max_suger))

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = [int(x) for x in input().split()]
threshold = e / (100 + e) * 100
max_concent = 0
max_total = 0
max_suger = 0
max_try_water = int(f / 100 * a)
max_try_suger = int(f / c)
for i in range(max_try):
    for j in range(max_try):
        for k in range(max_try):
            for l in range(max_try):                
                water = a * i * 100 + b * j * 100
                suger = c * k + d * l   
                if water == 0:
                    break
                concentration = suger / (water + suger) * 100
                if (water + suger > f or concentration > threshold) :
                    break
                else:
                    if concentration > max_concent:
                        max_concent = concentration
                        max_total = water + suger
                        max_suger = suger
print("{} {}".format(max_total, max_suger))

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=set([])
for i in range(31):
    for j in range(31):
        x=a*i*100+b*j*100
        if 0<x<=f:
            w.add(x)
s=set([])
for i in range(3001):
    for j in range(3001):
        y=c*i+d*j
        if y<=f:
            s.add(y)
tmpn=0
for i in w:
    for j in s:
        if i+j<=f and i//100*e>=j:
            if tmpn<j/(1.0*(i+j)):
                tmpn=j/(1.0*(i+j))
                ans=[i,j]
print(*ans)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
w=set([])
for i in range(31):
    for j in range(31):
        x=a*i*100+b*j*100
        if x<=f:
            w.add(x)
s=set([])
for i in range(3001):
    for j in range(3001):
        y=c*i+d*j
        if y<=f:
            s.add(y)
tmpn=0
for i in w:
    for j in s:
        if i+j<=f and i//100*e>=j:
            if tmpn<j/(1.0*(i+j)):
                tmpn=j/(1.0*(i+j))
                ans=[i,j]
print(*ans)

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split())
ans = [100 * A, 0]
c = 0

for i in range(1, F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        a = 100 * A * i + 100 * b * j
        if a < F:
            break
        for k in range((F - a) // C + 1):
            for l in range((F - a - C * k) // D + 1):
                b = C * k + D * l
                conc = 100 * b / (a + b)
                if b <= (A * i + B * j) * E and a + b < F:
                    if conc > c:
                        c = conc
                        ans = [a + b, b]
                else:
                    break
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
x=set()
for i in range(0,f+1,a):
    for j in range(0,f+1,b):
        if 0<(i+j)<=f:
            x.add(i+j)
y=set()
for i in range(0,f+1,c):
    for j in range(0,f+1,d):
        if 0<(i+j)<=f:
            y.add(i+j)

ans=[]
for n in x:
    for m in y:
        if n+m>f:
            continue
        if n*e<m*100:
            continue
        ans.append([n+m,m,m/n])

ans.sort(key=lambda x:x[2], reverse=True)

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

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
x=set()
for i in range(0,f+1,a):
    for j in range(0,f+1,b):
        if 0<(i+j)<=f:
            x.add(i+j)
y=set()
for i in range(0,f+1,c):
    for j in range(0,f+1,d):
        if 0<(i+j)<=f:
            y.add(i+j)

ans=[]
noudoma=e/100
for n in x:
    for m in y:
        if n==0:
            continue
        if m/n<=noudoma and (n+m)<=f:
            ans.append([n+m,m,m/(n+m)])

ans.sort(key=lambda x:x[2], reverse=True)


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

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
x=set()
for i in range(f//a+2):
    for j in range(f//b+2):
        if 0<(a*i+b*j)<=f:
            x.add(a*i+b*j)
y=set()
for i in range(f//c+2):
    for j in range(f//d+2):
        if 0<(c*i+d*j)<=f:
            y.add(c*i+d*j)

ans=[]
noudoma=e/100
for n in x:
    for m in y:
        if n==0:
            continue
        if m/n<=noudoma and (n+m)<=f:
            ans.append([n+m,m,m/(n+m)])

ans.sort(key=lambda x:x[2], reverse=True)


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

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
x=set()
for i in range(f//a+1):
    for j in range(f//b+1):
        if 0<(a*i+b*j)<=f:
            x.add(a*i+b*j)
y=set()
for i in range(f//c+1):
    for j in range(f//d+1):
        if 0<(c*i+d*j)<=f:
            y.add(c*i+d*j)

ans=[]
noudoma=e/100
for n in x:
    for m in y:
        if n==0:
            continue
        if m/n<=noudoma and (n+m)<=f:
            ans.append([n+m,m,m/(n+m)])

ans.sort(key=lambda x:x[2], reverse=True)


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

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
x=set()
for i in range(f//a+1):
    for j in range(f//b+1):
        if 0<(a*i+b*j)<=f:
            x.add(a*i+b*j)
y=set()
for i in range(f//c+1):
    for j in range(f//d+1):
        if 0<c*i+d*j<=f:
            y.add(c*i+d*j)

ans=[]
noudoma=e/100
for n in x:
    for m in y:
        if m/n<=noudoma and (n+m)<=f:
            ans.append([n+m,m,m/(n+m)])

ans.sort(key=lambda x:x[2], reverse=True)


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

Submission status: Runtime Error

Solution code:
from sys import stdin
import math
A, B, C, D, E, F = [int(x) for x in stdin.readline().rstrip().split()]

water = set()
for i in range(0, F//(100*A)+1):
    for j in range(0, F//(100*B)+1):
        water.add(A*i*100+B*j*100)

sugar = set()
capa = math.ceil(F/100)*E
for k in range(0, capa//C+1):
    for l in range(0, capa//D+1):
        sugar.add(C*k+D*l)

W = 0
S = 0
conc = 0
#print(water)
#print(sugar)
for w in water:
    for s in sugar:
        if w + s > F:
            continue
        if s > (w / 100)*E:
            continue
        tmp = (100*s)/(w+s)
        if tmp >= conc:
            conc = tmp
            W = w
            S = s
        #print(conc,w,s)
print(W+S,S)

Submission status: Runtime Error

Solution code:
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
data.sort()
ans=0
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
w_m=(f*100/(100+e))//100*100
s_m=f*e//(100+e)
answ=float('inf')
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if w!=0:
            for k in range(s_m//c+1):
                for l in range((s_m-k*c)//d+1):
                    s=k*c+l*d
                    if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                        answ=w
                        anss=s
print(answ+anss,anss)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f=map(int,input().split())
w_m=f//(100+e)*100
s_m=f//(100+e)*e
w=w_m//(100*a)*(100*a)
s=s_m//c*c
wn=w_m//(100*b)
sc=s_m//c
sd=s_m//d
noudo=0
answ=0
anss=0
for i in range(wn+1):
    for j in range(sc+1):
        for k in range((s_m-j*c)//d+1):
            s=j*c+k*d
            if (noudo<s/(s+w)) and (s/(s+w)<=e/(100+e)):
                noudo=s/(s+w)
                answ=w
                anss=s
    w+=b*100
    while w<=w_m:
        w-=a*100

print(answ+anss,anss)

Submission status: Runtime Error

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

water_list = []
suger_list = []

for i in range(F):
  if 100*A*i <= F:
    for j in range(F):
      if 100*B*j <= F:
        if 100*A*i + 100*B*j <= F:
          water_list.append(100*A*i + 100*B*j)
        else:
          break
      else:
        break
  else:
    break

for i in range(F):
  if C*i <= F:
    for j in range(F):
      if D*j <= F:
        if C*i + D*i <= F:
          suger_list.append(C*i+D*j)
        else:
          break
      else:
        break
  else:
    break

ans = 0
ans_list = []

for water in water_list:
  for suger in suger_list:
    if water != 0 and suger != 0:
      if suger/(water + suger) > ans and water+suger <= F and suger <= (water/100)*E:
        ans = suger/(water + suger)
        ans_list = [water,suger]

print(str(ans_list[0]+ans_list[1]) + " " + str(ans_list[1]))

Submission status: Runtime Error

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

water_list = []
suger_list = []

for i in range(F):
  for j in range(F):
    if 100*A*i + 100*B*j <= F:
      water_list.append(100*A*i + 100*B*j)

for i in range(F):
  for j in range(F):
    if C*i + D*i <= F:
      suger_list.append(C*i+D*j)

ans = 0
ans_list = []

for water in water_list:
  for suger in suger_list:
    if water != 0 and suger != 0:
      if suger/(water + suger) > ans and water+suger <= F and suger <= (water/100)*E:
        ans = suger/(water + suger)
        ans_list = [water,suger]

print(str(ans_list[0]+ans_list[1]) + " " + str(ans_list[1]))

Submission status: Runtime Error

Solution code:
17 19 22 26 55 2802

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int A, B, C, D, E, F;

int main(){
  cin >> A >> B >> C >> D >> E >> F;
  pair<int, int> ans = {-1, -1};
  double maxm = -1;
  for(int i = 0; A*i*100 < F; i++){
    for(int j = 0; (A*i+B*j)*100 < F; j++){
      if(i==0 && j ==0) continue;
      int water = (A*i+B*j)*100;
      for(int k = 0; water+k*C <= F && k*C <= E*water/100; k++){
        for(int l = 0; water+k*C+l+D <= F && (k*C+l*D) <= E*water/100; l++){
          int suger = C*k+D*l;
          if(suger > E*water/100) continue;
          if((double)100*suger/(suger+water) > maxm){
            ans.first = water+suger;
            ans.second = suger;
            maxm = (double)100*suger/(suger+water);
          }
        }
      }
    }
  }
  cout << ans.first << " " << ans.second << endl;

  return 0;
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int A, B, C, D, E, F;

int main(){
  cin >> A >> B >> C >> D >> E >> F;
  pair<int, int> ans = {-1, -1};
  double maxm = -1;
  for(int i = 0; A*i*100 < F; i++){
    for(int j = 0; (A*i+B*j)*100 < F; j++){
      if(i==0 && j ==0) continue;
      int water = (A*i+B*j)*100;
      for(int k = 0; water+k*C <= F && k*C <= E*water/100; k++){
        for(int l = 0; water+k*C+l+D <= F && (k*C+l*D) <= E*water/100; l++){
          int suger = C*k+D*l;
          if(suger > E*water/100) continue;
          if(100*suger/(suger+water) > maxm){
            ans.first = water+suger;
            ans.second = suger;
            maxm = 100*suger/(suger+water);
          }
        }
      }
    }
  }
  cout << ans.first << " " << ans.second << endl;

  return 0;
}

Submission status: Runtime Error

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

dic_w={}
i=0
while True:
    if (a*i*100)>f:
        break
    j=0
    while True:
        w=(a*i+b*j)*100
        if w>f:
            break
        else:
            dic_w[w]=dic_w.get(w,0)+1
        j+=1
    i+=1
list_w=list(dic_w.keys())
list_w.sort()

dic_s={}
max_s=int(e*f/(100+e))
i=0
while True:
    if c*i>max_s:
        break
    j=0
    while True:
        s=c*i+d*j
        if s>max_s:
            break
        else:
            dic_s[s]=dic_s.get(s,0)+1
        j+=1
    i+=1
list_s=list(dic_s.keys())
list_s.sort()

max_per=0
flag=False
ans_w=0
ans_s=0
for w in list_w:
    if flag==True:
        break
    for s in list_s:
        if s/(w/100)==e and s+w<=f:
            ans_w=w
            ans_s=s
            flag=True
            break
        if s/(w/100)>e:
            break
        if s/(w/100)>max_per and s+w<=f:
            ans_w=w
            ans_s=s
print('{} {}'.format(ans_w+ans_s,ans_s))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = tuple(map(int, input().split()))
max_con = 0
res = None
for l in range(100*A, F+1, 100):
    if l % (100 * A) == 0 or l % (100 * B) == 0:
        for e in range(1, E*(l//100)+1):
            if (e % C == 0 or e % D == 0) and  l + e <= F:
                if max_con < e / (l + e):
                    max_con = e / (l + e)
                    res = (l+e, e)
print(*res)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int,input().split( ))
mx = 0
ans = []
for i in range(f//(a*100)+1):
    sup_b = f-i*a*100
    
    for j in range(sup_b//(b*100)+1):
        wat = i*a*100 + j*b*100
        
        if wat > f or not wat:
            continue
        sup_sug = min(e*(wat/100), f - wat)

        
        for k in range(int(sup_sug//c)+1):
            l = (sup_sug - k*c)//d
            
            if (k*c + l*d)/wat > e/100:
                continue
                
            if mx < (k*c + l*d)/wat:
                mx = (k*c + l*d)/wat
                ans = [(k*c + l*d) + wat, k*c + l*d]

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

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = map(int,input().split())
A *= 100
B *= 100
check = 0
for i in range(F//A+1):
    for j in range((F-(A*i))//B+1):
        if i + j == 0:continue
        for k in range(((F-(A*i))-B*j)//C+1):
            for l in range((((F-(A*i))-B*j)-C*k)//D+1):
                water = A*i+B*j
                sugar = C*k+D*l
                if water//100*E < sugar:continue
                if check < 100*sugar/(water+sugar):
                    check = 100*sugar/(water+sugar)
                    ans = [water+sugar,sugar]
print(*ans)

Submission status: Runtime Error

Solution code:
def solve():
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
	for a in range(31):
		for b in range(31):
			for c in range(101):
				for d in range(101):
            		w = (100*A)*a + (100*B)*b
                	s = C*c + D*d
					if w ==0:
						break
					if w+s > F:
						break
					else:
						if w/100 * E >= s:
                            density = 100*s/(w+s)
                            memo[a,b,c,d] = density
    						max_v = max(memo.values())
	for k, v in memo.items():
		if v == max_v:
			print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
			break
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F = map(int,input().split())
noudo = E/(100+E)
_=min(A,B)
max_noudo=0
ans_weight=0
ans_suger=0
def chk(s,C,D):
    i=s//(C%100)
    j=s//(D%100)
    for _i in range(i+1):
        for _j in range(j+1):
            if s == C*_i + D*_j:
                return True
    return False
for water in range(100*_,F+1,100):
    if not chk(water,A*100,B*100):
        continue
    for suger in range(F-water,0,-1):
        temp_noudo = suger/(water+suger)
        if temp_noudo>noudo:
            continue
        elif chk(suger,C,D):
            if max_noudo<temp_noudo:
                max_noudo=temp_noudo
                ans_weight = water+suger
                ans_suger = suger
            if temp_noudo == noudo:
                print(ans_weight,ans_suger)
                exit()

print(ans_weight,ans_suger)

Submission status: Runtime Error

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

maxconc = 0.0
maxwater = 100*A
maxconc = 0

for i in range(F//(100*A)+1):
  for j in range((F-100*A*i)//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print('{0} {1}'.format(maxwater+maxsugar,maxsugar))

Submission status: Runtime Error

Solution code:
A, B, C, D, E, F = map(int, input().split(' '))
maxconc = 0.0
maxwater = 100*A
maxconc = 0

for i in range(F//(100*A)+1):
  for j in range((F-100*A*i)//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print('{0} {1}'.format(maxwater+maxsugar,maxsugar))

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxconc = 0.0
maxwater = 100*A
maxconc = 0

for i in range(F//(100*A)+1):
  for j in range((F-100*A*i)//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print('{0} {1}'.format(maxwater+maxsugar,maxsugar))

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxconc = 0.0
maxwater = 100*A
maxconc = 0

for i in range(F//(100*A)+1):
  for j in range((F-(100*A*i))//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print('{0} {1}'.format(maxwater+maxsugar,maxsugar))

Submission status: Runtime Error

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxconc = 0.0
maxwater = 100*A
maxconc = 0

for i in range(F//(100*A)+1):
  for j in range((F-(100*A*i))//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print(maxwater+maxsugar,maxsugar)

Submission status: Runtime Error

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

for i in range(F//(100*A)+1):
  for j in range((F-(100*A*i))//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print(maxwater+maxsugar,maxsugar)

Submission status: Runtime Error

Solution code:
a, b, c, d, e, f = map(int, input().split())
res = None
m = 0
for aa in range(0, f, 100 * a):
    for bb in range(0, f, 100 * b):
        w = aa + bb
        if w == 0 or aa + bb > f:
            continue
        r = f - w
        for cc in range(0, r, c):
            for dd in range(0, r, d):
                s = cc + dd
                if s + w > f or 100 * s > e * w:
                    continue
                mm = s / w
                if mm > m:
                    res = (w + s, s)
                    m = mm
print(*res)

Submission status: Runtime Error

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

val_max = 0
for a in range(0,1+F//(100*A)):
  for b in range(0,1+(F-100*A*a)//(100*B)):
    if (a==0)&(b==0):
      continue
    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())

val_max = 0
for a in range(0,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)