Problem:


Score : 300 points

Problem Statement

Snuke is making sugar water in a beaker.
Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.

Operation 1: Pour 100A grams of water into the beaker.

Operation 2: Pour 100B grams of water into the beaker.

Operation 3: Put C grams of sugar into the beaker.

Operation 4: Put D grams of sugar into the beaker.

In our experimental environment, E grams of sugar can dissolve into 100 grams of water.

Snuke will make sugar water with the highest possible density.

The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker.
Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it.
If there is more than one candidate, any of them will be accepted.

We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent.
Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.

Constraints

1 \leq A < B \leq 30

1 \leq C < D \leq 30

1 \leq E \leq 100

100A \leq F \leq 3 000

A, B, C, D, E and F are all integers.

Inputs

Input is given from Standard Input in the following format:

A B C D E F

Outputs

Print two integers separated by a space.
The first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it.

Sample Input 1

1 2 10 20 15 200

Sample Output 1

110 10

In this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances.

We can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once.
It is not possible to make sugar water with higher density.
For example, the following sequences of operations are infeasible:

If we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker.

If we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.

Sample Input 2

1 2 1 2 100 1000

Sample Output 2

200 100

There are other acceptable outputs, such as:

400 200

However, the output below is not acceptable:

300 150

This is because, in order to make 300 grams of sugar water containing 150 grams of sugar, we need to pour exactly 150 grams of water into the beaker, which is impossible.

Sample Input 3

17 19 22 26 55 2802

Sample Output 3

2634 934



Sample input:
1 2 10 20 15 200


Sample output:
110 10

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left 
#bisect_left(a,x):a[i]>=xとなるような最小のi.
#昇順ソートされたリストaに昇順を崩さずxを挿入できる位置s(0-index)を返す.
#a=[1,3,5,7,9,11,13,15,17,19]
#s = bisect_left(a,4)
#s=2
a,b,c,d,e,f=map(int,input().split())
wa=set()
a*=100
b*=100
for i in range((f+a-1)//a+1):
    for j in range((f+b-1)//b+1):
        if 1<=i*a+j*b<=f:
            wa.add(i*a+j*b)
su=set()
e=100*e/(100+e)
x=int(f*e//100)
for i in range((x+c-1)//c+1):
    for j in range((x+d-1)//d+1):
        if i*c+j*d<=x:
            su.add(i*c+j*d)
su=sorted(list(su))
# print(wa)
# print(su)
ans=0
x,y=0,0
e+=0.001
for i in wa:
    # print(i,su[bisect_left(su,f-i)-1],su[bisect_left(su,e*i/(100-e))-1])
    p=min(bisect_left(su,f-i),bisect_left(su,e*i/(100-e)))
    if p>0:
        if ans<=su[p-1]/(i+su[p-1]):
            ans=su[p-1]/(i+su[p-1])
            x,y=i,su[p-1]
print(x+y,y)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def v(a: int, b: int, c: int):
    if a < b:
        a, b = b, a
    if c % a == 0:
        return c
    minr = c
    for va in range(c // a + 1):
        minr = min(minr, (c - va * a) % b)
        if minr == 0:
            break
    return c - minr


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    ansa = A * 100
    anss = 0
    for w in range(1, F // 100 + 1):
        w2 = v(B, A, w)
        if w != w2:
            continue
        s = w2 * E
        s2 = v(D, C, s)
        a2 = s2 + w2 * 100
        if a2 > F:
            continue
        # anss / ansa < s2 / a2
        if anss * a2 < ansa * s2:
            ansa, anss = a2, s2
    print(ansa, anss)


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: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def v(a: int, b: int, c: int):
    if a < b:
        a, b = b, a
    if c % a == 0:
        return c
    minr = c
    for va in range(c // a + 1):
        minr = min(minr, (c - va * a) % b)
        if minr == 0:
            break
    return c - minr


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    ansa = A
    anss = 0
    for w in range(1, F // 100 + 1):
        w2 = v(B, A, w)
        if w != w2:
            continue
        s = w2 * E
        s2 = v(D, C, s)
        a2 = s2 + w2 * 100
        if a2 > F:
            continue
        # anss / ansa < s2 / a2
        if anss * a2 < ansa * s2:
            ansa, anss = a2, s2
    print(ansa, anss)


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: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def v(a: int, b: int, c: int):
    if a < b:
        a, b = b, a
    if c % a == 0:
        return c
    minr = c
    for va in range(c // a + 1):
        minr = min(minr, (c - va * a) % b)
        if minr == 0:
            break
    return c - minr


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    ansa = 0
    anss = -1
    for w in range(1, F // 100 + 1):
        w2 = v(B, A, w)
        if w != w2:
            continue
        s = w2 * E
        s2 = v(D, C, s)
        a2 = s2 + w2 * 100
        if a2 > F:
            continue
        # anss / ansa < s2 / a2
        if anss * a2 < ansa * s2:
            ansa, anss = a2, s2
    print(ansa, anss)


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: Wrong Answer

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a, b, c, d, e, f = IN()
	mm=f
	ww_list=[0]*(mm+1)
	ww_list[0]=1
	for i, is_ok in enumerate(ww_list):
		if is_ok == 1:
			if i+(a*100) <= mm:
				ww_list[i+(a*100)]=1
			if i+(b*100) <= mm:
				ww_list[i+(b*100)]=1
				
	max_noudo=0
	ret_sw=0
	ret_suger=0
	for wv, is_ok_w in enumerate(ww_list):
		if is_ok_w == 0:
			continue
		suger_limit=e*(wv//100)
		ok_s=[0]*(suger_limit + 1)
		ok_s[0]=1
		max_suger=0
		for i, is_ok in enumerate(ok_s):
			if is_ok == 1:
				if i + c <= suger_limit and (wv+i+c) <= f:
					ok_s[i+c]=1
					max_suger=max(max_suger, i+c)
				if i+d <= suger_limit and (wv+i+d) <= f:
					ok_s[i+d]=1
					max_suger = max(max_suger, i+d)
		if wv == 0:
				continue
			
		suger_noudo=((100*max_suger)/(wv+max_suger))
		if max_noudo < suger_noudo:
			max_noudo=suger_noudo
			ret_sw = wv+max_suger
			ret_suger = max_suger
	print(ret_sw, ret_suger)
	return 
				
		
	
	

	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a, b, c, d, e, f = IN()
	mm=f
	ww_list=[0]*(mm+1)
	ww_list[0]=1
	for i, is_ok in enumerate(ww_list):
		if is_ok == 1:
			if i+(a*100) <= mm:
				ww_list[i+(a*100)]=1
			if i+(b*100) <= mm:
				ww_list[i+(b*100)]=1
	max_noudo=0
	ret_sw=0
	ret_suger=0
	
	for wv, is_ok_w in enumerate(ww_list):
		if is_ok_w == 0:
			continue
		suger_limit=e*wv//100
		ok_s=[0]*(suger_limit +1)
		ok_s[0]=1
		max_suger=0
		for i, is_ok in enumerate(ok_s):
			if is_ok == 1:
				if i + c <= suger_limit and (wv+i+c) <= f:
					ok_s[i+c]=1
					max_suger=max(max_suger, i+c)
				if i+d <= suger_limit and (wv+i+d) <= f:
					ok_s[i+d]=1
					max_suger = max(max_suger, i+d)
			if wv == 0:
				continue
			
			suger_noudo=((100*max_suger)/(wv+max_suger))
			if max_noudo < suger_noudo:
				max_noudo=suger_noudo
				ret_sw = wv+max_suger
				ret_suger = max_suger
	print(ret_sw, ret_suger)
	return 
				
		
	
	

	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def v(a: int, b: int, c: int):
    if a < b:
        a, b = b, a
    if c % a == 0:
        return c
    minr = c
    for va in range(c // a + 1):
        minr = min(minr, (c - va * a) % b)
        if minr == 0:
            break
    return c - minr


def solve(A: int, B: int, C: int, D: int, E: int, F: int):
    ansa = 0
    anss = 0
    for w in range(1, F // 100 + 1):
        w2 = v(A, B, w)
        if w != w2:
            continue
        s = w2 * E
        s2 = v(C, D, s)
        a2 = s2 + w2 * 100
        if a2 > F:
            continue
        # anss / ansa <= s2 / a2
        if anss * a2 <= ansa * s2:
            ansa, anss = 100 * w2 + s2, s2
    print(ansa, anss)


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: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
res=-1
ans=[0,0]
s1=set()
s2=set()
for x in range(0,f+1,100*a):
  for y in range(0,f+1-x,100*b):
    s1.add(x+y)
for x in range(0,f+1,c):
  for y in range(0,f+1-x,d):
    s2.add(x+y)
for x in s1:
  for y in s2:
    if x>0 and x*e/100>=y and x+y<=f:
      tmp=y/(x+y)
      if tmp>res:
        tmp=res
        ans=[x+y,y]
print(*ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
tmp=0
ans=[0,0]
for x in range(31):
  for y in range(31):
    if x==0 and y==0:
      continue
    for z in range(10**4+1):
      w=(f-100*a*x-100*b*y-c*z)//d
      if w>=0:
        dens=(c*z+d*w)/(100*a*x+100*b*y+c*z+d*w)
        if dens>tmp:
          tmp=dens
          ans=[100*a*x+100*b*y+c*z+d*w,c*z+d*w]
print(*ans)

Submission status: Wrong Answer

Solution code:
from itertools import product

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

max_conc = 0
res = [100*a, 0]
for w1, w2 in product(range(0, f+1, 100*a), range(0, f+1, 100*b)):
    if w1 + w2 > f or w1 == w2 == 0:
        continue
    for s1 in range(0, f-w1-w2+1, c):
        s2 = (min(f-w1-w2, (w1 + w2) // 100 * e) - s1) // d * d
        if s2 < 0:
            continue
        conc = (s1 + s2) / (w1 + w2 + s1 + s2) * 100
        if conc > max_conc:
            print(w1, w2, s1, s2)
            max_conc = conc
            res = [w1 + w2 + s1 + s2, s1 + s2]

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

Submission status: Wrong Answer

Solution code:
from itertools import product

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

max_conc = 0
res = [100*a, 0]
for w1, w2 in product(range(0, f+1, 100*a), range(0, f+1, 100*b)):
    if w1 + w2 > f or w1 == w2 == 0:
        continue
    for s1 in range(0, f-w1-w2+1, c):
        s2 = (min(f-w1-w2, (w1 + w2) // 100 * e) - s1) // d * d
        conc = (s1 + s2) / (w1 + w2 + s1 + s2) * 100
        if conc > max_conc:
            max_conc = conc
            res = [w1 + w2 + s1 + s2, s1 + s2]

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

Submission status: Wrong Answer

Solution code:
import sys 
input = sys.stdin.readline
MOD = 10**9 +7
INF = 10**9
from bisect import bisect_right

def main():
    a,b,c,d,e,f = map(int,input().split())
    a *= 100
    b *= 100
    X = []
    Y = []
    for i in range(f//a + 1):
        for j in range((f - a * i)//b + 1):
            if i == 0 and j == 0:
                continue
            X.append(a * i + b * j)
    
    for i in range(f//c + 1):
        for j in range((f - i * c)//d + 1):
            Y.append((c * i + d * j))
    Y.sort()
    c = 0
    ans = (0,0)
    for x in X:
        lim = min(e * x // 100, f - x)
        idx = bisect_right(Y, lim)
        if idx == 0:
            continue
        else:
            y = Y[idx - 1]
            if c * (x + y) < y:
                c = y / (x + y)
                ans = (x + y, y)
    
    print(*ans)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int,input().split())
 
suger_max = int(f * e/(100+e))
 
water, suger = [], [] 
 
for i in range(f//(a*100) + 1):
    for j in range(f//(b*100) + 1):
        temp = a * 100 * i + b * 100 * j
        if temp <= f and 0 < temp:
            water.append(temp)

for p in range(suger_max//c + 1):
    for q in range(suger_max//d + 1):
        if c * p + d * q <= suger_max:
            suger.append(c * p + d * q) 
 
z = [0, 0, 0]
for x in suger:
    for y in water:
        temp = x / (x + y) 
        if temp <= e/(100+e) and x + y <= f:
            if z[0] < temp:
                z[0] = temp
                z[1] = x + y
                z[2] = x
 
if a * 100 ==f:
    print(a * 100, 0)
else:
    print(*z[1:3])

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int,input().split())
 
suger_max = int(f * e/(100+e))
 
water, suger = [], [] 
 
for i in range(f//(a*100) + 1):
    for j in range(f//(b*100) + 1):
        temp = a * 100 * i + b * 100 * j
        if temp <= f and 0 < temp:
            water.append(temp)  
 
for p in range(suger_max//c + 1):
    for q in range(suger_max//d + 1):
        if c * p + d * q <= suger_max:
            suger.append(c * p + d * q) 
 
z = [0, 0, 0]
for x in suger:
    for y in water:
        temp = x / (x + y) 
        if temp <= e/(100+e) and x + y <= f:
            if z[0] < temp:
                z[0] = temp
                z[1] = x + y
                z[2] = x
 
print(*z[1:3])

Submission status: Wrong Answer

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

suger_max = int(f * e/(100+e))
print(suger_max)

water, suger = [], [] 

for i in range(f//(a*100) + 1):
    for j in range(f//(b*100) + 1):
        temp = a * 100 * i + b * 100 * j
        if temp <= f and 0 < temp:
            water.append(temp)  

for p in range(suger_max//c + 1):
    for q in range(suger_max//d + 1):
        if c * p + d * q <= suger_max:
            suger.append(c * p + d * q) 

z = [0, 0, 0]
for x in suger:
    for y in water:
        temp = x / (x + y) 
        if temp <= e/(100+e) and x + y <= f:
            if z[0] < temp:
                z[0] = temp
                z[1] = x + y
                z[2] = x

print(z)

Submission status: Wrong Answer

Solution code:
#083c
import sys

A,B,C,D,E,F = map(int, input().split())
#水*100、水*100、砂糖、砂糖

#合計はF以下、溶け残りはダメ
#水100に対してE溶ける → 100E/(100+E) が最大値

#砂糖水の濃度は 100b/(a+b)
#水a,砂糖b

max_conc = 0
total_weight_at_max_conc = 0
sugar_weight_at_max_conc = 0

for h in range(0, 1+int(F/(100*A))): #F<=3000,1<=Aより 最大30回ループ
    limit_water = F - (h*100*A)
    
    for i in range(0, 1+int(limit_water/(100*B))):
        limit_total_sugar_by_weight = F - (h*100*A + i*100*B)
        limit_total_sugar_by_conc = (h*100*A + i*100*B)/100*E
        limit_total_sugar = min(limit_total_sugar_by_weight,limit_total_sugar_by_conc)
            
        for j in range(0, 1+int(limit_total_sugar/C)):
            limit_D_sugar_by_weight = F - (h*100*A + i*100*B + j*C)
            limit_D_sugar_by_conc = (h*100*A + i*100*B)/100*E - j*C
            limit_D_sugar = min(limit_D_sugar_by_weight,limit_D_sugar_by_conc) 
            
            k = int(limit_D_sugar/D) #濃度を濃くするために操作Dは限界まで行う。
            
            if h>=0 and i>=0 and j>=0 and k>=0:
                a = h*100*A + i*100*B
                b = j*C + k*D
                total_weight = a + b
                
                #print(h,i,j,k)
                #print(a,b)
                
                if a + b != 0:
                    concentration = 100*b/(a+b)

                    if concentration > max_conc:
                        max_conc = concentration
                        total_weight_at_max_conc = total_weight
                        sugar_weight_at_max_conc = b

                        if max_conc == 100*E/(100+E):
                            print(total_weight_at_max_conc,sugar_weight_at_max_conc)
                            sys.exit()

print(total_weight_at_max_conc,sugar_weight_at_max_conc)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

water = []
for a in range(30):
    for b in range(30):
        w = 100*A*a + 100*B*b
        if w == 0: continue
        if w <= F: water.append(w)
        else: break

sugar = []
for c in range(3000):
    for d in range(3000):
        s = c*C + d*D
        if s <= F: sugar.append(s)
        else: break

d = 0
anss = 0
answ = 0
for w in water:
    for s in sugar:
        if w+s > F or w*E < 100*s:
            continue
        tmpd = (100*s)/(w+s)
        if tmpd > d:
            d = tmpd
            anss = s
            answ = w

print(anss+answ, anss)

Submission status: Wrong Answer

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B, C, D, E, F = map(int, input().split())
    rate = 0
    res_water = A * 100
    res_sugar = 0
    for i in range(30//A+1):
        for j in range(30//B+1):
            if i==0 and j==0:
                continue
            water = A*i + B*j
            if water*100 > F:
                continue
            limit = water * E
            for s in range(limit//C+1):
                sugar = limit - (limit-C*s)%D
                if water*100 + sugar > F:
                    continue
                if rate <= sugar/(sugar+water*100):
                    rate = sugar/(sugar+water*100)
                    res_water = water * 100
                    res_sugar = sugar
    print(res_water+res_sugar, res_sugar)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B, C, D, E, F = map(int, input().split())
    rate = 0
    res_water = A * 100
    res_sugar = 0
    for i in range(30//A+1):
        for j in range(30//B+1):
            if i==0 and j==0:
                continue
            water = A*i + B*j
            if water*100 > F:
                continue
            limit = water * E
            for s in range(limit//C+1):
                sugar = limit - (limit-C*s)%D
                if water*100 + sugar > F:
                    continue
                if rate < sugar/(sugar+water*100):
                    rate = sugar/(sugar+water*100)
                    res_water = water * 100
                    res_sugar = sugar
    print(res_water+res_sugar, res_sugar)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B, C, D, E, F = map(int, input().split())
    rate = 0
    res_water = min(A, B) * 100
    res_sugar = 0
    for i in range(30//A+1):
        for j in range(30//B+1):
            if i==0 and j==0:
                continue
            water = A*i + B*j
            if water*100 > F:
                continue
            limit = water * E
            for s in range(limit//C+1):
                sugar = limit - (limit-C*s)%D
                if water*100 + sugar > F:
                    continue
                if rate < sugar/(sugar+water*100):
                    rate = sugar/(sugar+water*100)
                    res_water = water * 100
                    res_sugar = sugar
    print(res_water+res_sugar, res_sugar)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B, C, D, E, F = map(int, input().split())
    rate = 0
    res_water = 0
    res_sugar = 0
    for i in range(30//A+1):
        for j in range(30//B+1):
            if i==0 and j==0:
                continue
            water = A*i + B*j
            if water*100 > F:
                continue
            limit = water * E
            for s in range(limit//C+1):
                sugar = limit - (limit-C*s)%D
                if water*100 + sugar > F:
                    continue
                if rate < sugar/(sugar+water*100):
                    rate = sugar/(sugar+water*100)
                    res_water = water * 100
                    res_sugar = sugar
    print(res_water+res_sugar, res_sugar)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
water_reps = []
sugar_reps = []
for i in range(0, 3001, 100 * a):
    for j in range(0, 3001, 100 * b):
        if 0 < (i + j):
            water_reps.append(i + j)
for i in range(0, min(30 * e, 1501), c):
    for j in range(0, min(30 * e, 1501), d):
        sugar_reps.append(i + j)
water_reps = list(set(water_reps))
sugar_reps = list(set(sugar_reps))
water_reps.sort()
sugar_reps.sort()
ans = [(water_reps[1] + sugar_reps[0]), sugar_reps[0]]
for water in water_reps:
    for sugar in sugar_reps:
        if sugar <= (water // 100) * e and (water + sugar) <= f:
            conc = sugar / (water + sugar)
            if (ans[1] / ans[0]) < conc:
                ans = [(water + sugar), sugar]
print(*ans)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
water_reps = []
sugar_reps = []
for i in range(0, 3001, 100 * a):
    for j in range(0, 3001, 100 * b):
        water_reps.append(i + j)
for i in range(0, min(30 * e, 1501), c):
    for j in range(0, min(30 * e, 1501), d):
        sugar_reps.append(i + j)
water_reps = list(set(water_reps))
sugar_reps = list(set(sugar_reps))
water_reps.sort()
water_reps = water_reps[1:]
sugar_reps.sort()
ans = [(water_reps[1] + sugar_reps[0]), sugar_reps[0]]
for water in water_reps:
    for sugar in sugar_reps:
        if sugar <= (water // 100) * e and (water + sugar) <= f:
            conc = sugar / (water + sugar)
            if (ans[1] / ans[0]) < conc:
                ans = [(water + sugar), sugar]
print(*ans)

Submission status: Wrong Answer

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

water = [0 for _ in range(30 + 1)]
sugar = [0 for _ in range(3000 + 1)]

water[0] = 1
sugar[0] = 1

for i in range(30):
    if water[i]:
        if i + A <= 30:
            water[i + A] = 1
        if i + B <= 30:
            water[i + B] = 1

for j in range(3000):
    if sugar[j]:
        if j + C <= 3000:
            sugar[j + C] = 1
        if j + D <= 3000:
            sugar[j + D] = 1

concentration = 0
ans = (100, 0)

for i in range(31):
    if not water[i]:
        continue
    for j in range(3001):
        if not sugar[j]:
            continue
        if i + j == 0 or 100 * i + j > F or j > E * i:
            continue
        if concentration * (100 * i + j) < 100 * j:
            concentration = (100 * j) / (100 * i + j)
            ans = (100 * i + j, j)

print(*ans)

Submission status: Wrong Answer

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

water = [0 for _ in range(30 + 1)]
sugar = [0 for _ in range(3000 + 1)]

water[0] = 1
sugar[0] = 1

for i in range(30):
    if water[i]:
        if i + A <= 30:
            water[i + A] = 1
        if i + B <= 30:
            water[i + B] = 1

for j in range(3000):
    if sugar[j]:
        if j + C <= 3000:
            sugar[j + C] = 1
        if j + D <= 3000:
            sugar[j + D] = 1

concentration = 0
ans = (0, 0)

for i in range(31):
    if not water[i]:
        continue
    for j in range(3001):
        if not sugar[j]:
            continue
        if i + j == 0 or 100 * i + j > F or j > E * i:
            continue
        if concentration * (100 * i + j) < 100 * j:
            concentration = (100 * j) / (100 * i + j)
            ans = (100 * i + j, j)

print(*ans)

Submission status: Wrong Answer

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

# 入れられるwaterの量ベクトル
ws = 0
while ws*a*100 <= f:
  water = ws * a
  while water*100 <= f:
    if water not in w and water != 0:
      w.append(water)
    water += b
  ws += 1

# 入れられるsugarの最大量ベクトル
ans = [1,0]
for wb in range(len(w)):
  sc = 0
  sd = 0
  ss = 0
  while sc/w[wb] <= e and sc + w[wb]*100 <= f:
    suger = sc * c
    while suger/w[wb] <= e and suger + w[wb]*100 <= f:
      if ss < suger:
        ss = suger
      suger += d
    sc += 1
  
  if ss/w[wb] > ans[1]/ans[0]:
    ans = [w[wb] , ss]
print(' '.join(map(str,[ans[0]*100+ans[1],ans[1]])))

Submission status: Wrong Answer

Solution code:
a100, b100, csuger, dsuger, e100suger, fmax = map(int, input().split())
maxmizu = fmax / (1 + e100suger / 100)
maxsuger = maxmizu * e100suger // 100
water = 0
waterlist = []
watera = max([a100*100, b100*100])
waterb = min([a100*100, b100*100])
for b in range(int(maxmizu//waterb)+2):
    for a in range(int(maxmizu//watera)+2):
        dst = b * waterb + a * watera
        if dst > maxmizu:
            break
        waterlist.append(dst)
waterlist.sort(reverse=True)
for i in waterlist:
    if maxmizu > i:
        water = i
        break
suger = 0
sugerlist = []
sugera = max([csuger, dsuger])
sugerb = min([csuger, dsuger])
for b in range(int(maxsuger//sugerb)+2):
    for a in range(int(maxsuger//sugera)+2):
        dst = b * sugerb + a * sugera
        if dst > maxsuger or dst > water / 100 * e100suger:
            break
        sugerlist.append(dst)
sugerlist.sort(reverse=True)
for i in sugerlist:
    if maxsuger > i:
        suger = i
        break
dst = str(water + suger) + " " + str(suger)
print(dst)

Submission status: Wrong Answer

Solution code:
a100, b100, csuger, dsuger, e100suger, fmax = map(int, input().split())
maxmizu = fmax / (1 + e100suger / 100)
maxsuger = maxmizu * e100suger // 100
water = 0
waterlist = []
watera = max([a100*100, b100*100])
waterb = min([a100*100, b100*100])
for b in range(int(maxmizu//waterb)+1):
    for a in range(int(maxmizu//watera)+1):
        dst = b * waterb + a * watera
        if dst > maxmizu:
            break
        waterlist.append(dst)
waterlist.sort(reverse=True)
for i in waterlist:
    if maxmizu > i:
        water = i
        break
suger = 0
sugerlist = []
sugera = max([csuger, dsuger])
sugerb = min([csuger, dsuger])
for b in range(int(maxsuger//sugerb)+1):
    for a in range(int(maxsuger//sugera)+1):
        dst = b * sugerb + a * sugera
        if dst > maxsuger or dst > water / 100 * e100suger:
            break
        sugerlist.append(dst)
sugerlist.sort(reverse=True)
for i in sugerlist:
    if maxsuger > i:
        suger = i
        break
dst = str(water + suger) + " " + str(suger)
print(dst)

Submission status: Wrong Answer

Solution code:
a100, b100, csuger, dsuger, e100suger, fmax = map(int, input().split())
maxmizu = fmax / (1 + e100suger / 100)
maxsuger = maxmizu * e100suger // 100
water = 0
watera = max([a100*100, b100*100])
waterb = min([a100*100, b100*100])
while maxmizu - waterb > water:
    if maxmizu - water > watera:
        water += watera
    elif maxmizu - water > waterb:
        water += waterb
suger = 0
sugerlist = []
sugera = max([csuger, dsuger])
sugerb = min([csuger, dsuger])
for b in range(int(maxsuger//sugerb)+1):
    for a in range(int(maxsuger//sugera)+1):
        dst = b * sugerb + a * sugera
        if dst > maxsuger or dst > water / 100 * e100suger:
            break
        sugerlist.append(dst)
sugerlist.sort(reverse=True)
for i in sugerlist:
    if maxsuger > i:
        suger = i
        break
dst = str(water + suger) + " " + str(suger)
print(dst)