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:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    A,B,C,D,E,F = LI()

    w = []
    for i in range(math.ceil(F/A/100)+1):
        for j in range(math.ceil(F/B/100)+1):
            if 0 < A*i+B*j <= int(F/100):
                w.append((A*i+B*j)*100)
    s = []
    for i in range(math.ceil(F*E/100/C)+1):
        for j in range(math.ceil(F*E/100/D)+1):
            if 0 <= C*i+D*j <= int(F*E/100):
                s.append(C*i+D*j)

    max_E = -1.0
    ans_w = 0
    ans_s = 0
    for x in w:
        for y in s:
            if x + y <= F and max_E < y/(x+y)*100 <= E:
                max_E = y/(x+y) * 100
                ans_w = x + y
                ans_s = y
    print(ans_w,ans_s)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    A,B,C,D,E,F = LI()

    w = []
    for i in range(math.ceil(F/A/100)+1):
        for j in range(math.ceil(F/B/100)+1):
            if 0 < A*i+B*j <= int(F/100):
                w.append((A*i+B*j)*100)
    w.sort()
    s = []
    for i in range(math.ceil(F*E/100/C)+1):
        for j in range(math.ceil(F*E/100/D)+1):
            if 0 <= C*i+D*j <= int(F*E/100):
                s.append(C*i+D*j)
    s.sort()

    max_E = -1.0
    ans_w = 0
    ans_s = 0
    for x in w:
        for y in s:
            if x + y <= F and max_E < y/x*100 <= E:
                max_E = y/x * 100
                ans_w = x + y
                ans_s = y
    print(ans_w,ans_s)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    A,B,C,D,E,F = LI()

    w = []
    for i in range(math.ceil(F/A/100)+1):
        for j in range(math.ceil(F/B/100)+1):
            if 0 < A*i+B*j <= int(F/100):
                w.append((A*i+B*j)*100)
    w.sort()
    s = []
    for i in range(math.ceil(F*E/100/C)+1):
        for j in range(math.ceil(F*E/100/D)+1):
            if 0 < C*i+D*j <= int(F*E/100):
                s.append(C*i+D*j)
    s.sort()

    max_E = 0.0
    ans_w = 0
    ans_s = 0
    for x in w:
        for y in s:
            if x + y <= F and y/x*100 <= E:
                if y/x*100 > max_E:
                    max_E = y/x *100
                    ans_w = x + y
                    ans_s = y
    if max_E == 0.0:
        ans_w = A * 100
    print(ans_w,ans_s)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    A,B,C,D,E,F = LI()

    w = []
    for i in range(math.ceil(F/A/100)):
        for j in range(math.ceil(F/B/100)):
            if 0 < A*i+B*j <= int(F/100):
                w.append((A*i+B*j)*100)
    w.sort()
    s = []
    for i in range(math.ceil(F*E/100/C)):
        for j in range(math.ceil(F*E/100/D)):
            if 0 < C*i+D*j <= int(F*E/100):
                s.append(C*i+D*j)
    s.sort()

    max_E = 0.0
    ans_w = 0
    ans_s = 0
    for x in w:
        for y in s:
            if x + y <= F and y/x*100 <= E:
                if y/x*100 > max_E:
                    max_E = y/x *100
                    ans_w = x + y
                    ans_s = y
    if max_E == 0.0:
        ans_w = A * 100
    print(ans_w,ans_s)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    A,B,C,D,E,F = LI()

    w = []
    for i in range(math.ceil(F/A/100)):
        for j in range(math.ceil(F/B/100)):
            if 0 < A*i+B*j <= int(F/100):
                w.append((A*i+B*j)*100)
    w.sort()
    s = []
    for i in range(math.ceil(F*E/100/C)):
        for j in range(math.ceil(F*E/100/D)):
            if 0 < C*i+D*j <= int(F*E/100):
                s.append(C*i+D*j)
    s.sort()

    max_E = 0.0
    ans_w = 0
    ans_s = 0
    for x in w:
        for y in s:
            if x + y <= F and y/x*100 <= E:
                if y/x*100 > max_E:
                    max_E = y/x *100
                    ans_w = x + y
                    ans_s = y
    print(ans_w,ans_s)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import combinations
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    water = [a * i + b * j for i in range(f // a + 1) for j in range(f // b + 1)]
    sugar = [c * i + d * j for i in range(f // c + 1) for j in range(f // d + 1)]

    tmp = 0
    x, y = 0, 0
    for w in water:
        if w == 0:
            continue
        for s in sugar:
            if s + w > f:
                continue
            if s * 100 <= e * w and tmp < s / (s + w):
                tmp = s / (s + w)
                x = s + w
                y = s
    print(x, y)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import combinations
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    water = [a * i + b * j for i in range(f // a + 1) for j in range(f // b + 1)]
    sugar = [c * i + d * j for i in range(f // c + 1) for j in range(f // d + 1)]
    water.sort()
    sugar.sort(reverse=True)

    for w in water:
        if w == 0:
            continue
        for s in sugar:
            if s + w > f:
                continue
            if s * 100 <= e * w:
                print(s + w, s)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import combinations
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    water = [a * i + b * j for i in range(f // a + 1) for j in range(f // b + 1)]
    sugar = [c * i + d * j for i in range(f // c + 1) for j in range(f // d + 1)]
    water.sort()
    sugar.sort(reverse=True)

    for w in water[1:]:
        for s in sugar:
            if s + w > f:
                continue
            if s * 100 <= e * w:
                print(s + w, s)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import combinations
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    aa = [a * i for i in range(f // a + 1)]
    bb = [b * i for i in range(f // b + 1)]
    cc = [c * i for i in range(f // c + 1)]
    dd = [d * i for i in range(f // d + 1)]

    tmp = 0
    x, y = 0, 0
    for _a in aa:
        for _b in bb:
            for _c in cc:
                for _d in dd:
                    w = _a + _b
                    s = _c + _d
                    total = s + w
                    if total == 0 or total > f:
                        continue
                    if s * 100 <= e * w and s / (s + w) > tmp:
                        tmp = s / (s + w)
                        x = total
                        y = s
    print(x, y)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d, e, f = map(int, input().split())
    aa, bb, cc, dd = f // (100 * a), f // (100 * b), f // c, f // d
    aaa, bbb, ccc, ddd = range(aa + 1), range(bb + 1), range(cc + 1), range(dd + 1)
    n = 0
    ans = (0, 0)
    for i in aaa:
        for j in bbb:
            for k in ccc:
                for l in ddd:
                    w = 100 * (a * i + b * j)
                    s = c * k + d * l

                    if w == 0:
                        continue

                    m = s / (w + s)

                    ok = (s + w <= f) and (100 * s <= e * w) and (m > n)
                    if ok:
                        n = m
                        ans = (s + w, s)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import product
    a, b, c, d, e, f = map(int, input().split())
    aa, bb, cc, dd = f // (100 * a), f // (100 * b), f // c, f // d
    aaa, bbb, ccc, ddd = range(aa + 1), range(bb + 1), range(cc + 1), range(dd + 1)
    n = 0
    ans = (0, 0)
    for i in aaa:
        for j in bbb:
            for k in ccc:
                for l in ddd:
                    w = 100 * (a * i + b * j)
                    s = c * k + d * l

                    if w == 0:
                        continue

                    m = 100 * s / w

                    ok = (s + w <= f) and (100 * s <= e * w) and (m > n)
                    if ok:
                        n = m
                        ans = (s + w, s)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import product
    a, b, c, d, e, f = map(int, input().split())
    aa, bb, cc, dd = f // (100 * a), f // (100 * b), f // c, f // d
    aaa, bbb, ccc, ddd = range(aa + 1), range(bb + 1), range(cc + 1), range(dd + 1)
    n = 0
    ans = (0, 0)
    for (k, l, i, j) in product(ccc, ddd, aaa, bbb):
        w = 100 * (a * i + b * j)
        s = c * k + d * l

        if w == 0:
            continue

        m = 100 * s / w

        ok = (s + w <= f) and (100 * s <= e * w) and (m > n)
        if ok:
            n = m
            ans = (s + w, s)
        
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import product
    a, b, c, d, e, f = map(int, input().split())
    a, b = max(a, b), min(a, b)
    c, d = max(c, d), min(c, d)
    aa, bb, cc, dd = f // (100 * a), f // (100 * b), f // c, f // d
    aaa, bbb, ccc, ddd = range(aa + 1), range(bb + 1), range(cc, -1, -1), range(dd, -1, -1)
    n = 0
    ans = (0, 0)
    for (k, l, j, i) in product(ddd, ccc, bbb, aaa):
        w = 100 * (a * i + b * j)
        s = c * k + d * l

        if w == 0:
            continue

        m = 100 * s / w

        ok = (s + w <= f) and (100 * s <= e * w) and (m >= n)
        if ok:
            n = m
            ans = (s + w, s)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import product
    a, b, c, d, e, f = map(int, input().split())
    a, b = max(a, b), min(a, b)
    c, d = max(c, d), min(c, d)
    aa, bb, cc, dd = f // (100 * a), f // (100 * b), f // c, f // d
    aaa, bbb, ccc, ddd = range(aa + 1), range(bb + 1), range(cc, -1, -1), range(dd, -1, -1)
    n = 0
    ans = (0, 0)
    for (k, l, j, i) in product(ddd, ccc, bbb, aaa):
        w = 100 * (a * i + b * j)
        s = c * k + d * l

        if w == 0:
            continue

        m = 100 * s / w

        ok = (s + w <= f) and (100 * s <= e * w)
        if ok:
            n = m
            ans = (s + w, s)
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import product
    a, b, c, d, e, f = map(int, input().split())
    aa, bb, cc, dd = f // (100 * a), f // (100 * b), f // c, f // d
    aaa, bbb, ccc, ddd = range(aa + 1), range(bb + 1), range(cc, -1, -1), range(dd, -1, -1)
    n = 0
    ans = (0, 0)
    for (k, l, j, i) in product(ddd, ccc, bbb, aaa):
        w = 100 * (a * i + b * j)
        s = c * k + d * l

        if w == 0:
            continue

        m = 100 * s / w

        ok = (s + w <= f) and (100 * s <= e * w)
        if ok:
            n = m
            ans = (s + w, s)
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import product
    a, b, c, d, e, f = map(int, input().split())
    aa, bb, cc, dd = f // (100 * a), f // (100 * b), f // c, f // d
    aaa, bbb, ccc, ddd = range(aa+1), range(bb+1), range(cc, -1, -1), range(dd, -1, -1)
    n = 0
    ans = (0, 0)
    for (i, j, k, l) in product(aaa, bbb, ccc, ddd):
        w = 100 * (a * i + b * j)
        s = c * k + d * l

        if w == 0:
            continue

        m = 100 * s / w

        ok = (s + w <= f) and (100 * s <= e * w)
        if ok:
            n = m
            ans = (s + w, s)
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    a, b = min(a, c), max(a, b)
    c, d = min(c, d), max(c, d)
    ans = (0, 0)
    p = 0
    for w in range(1, f + 1):
        for s in range(1, f - w + 1):
            x = fnc(100 * a, 100 * b, w)
            y = fnc(c, d, s)
            z = s * 100 <= e * w
            if x and y and z:
                q = 100 * s / (s + w)
                if p <= q:
                    p = q
                    ans = (s+w, s)

    print(ans)


def fnc(x, y, z):
    if z % x == 0:
        return True
    if z % y == 0:
        return True
    n = z // x
    for i in range(1, n + 1):
        rem = z - x * i
        if rem % y == 0:
            return True
    else:
        return False


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i

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

waVa = maxValue(a*100,b*100,f)
suVa = maxValue(c,d,f-waVa)
maxR = 0

anw = waVa
ans = suVa

while 1:
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa == 0:
		break
	if maxR<100*suVa/(suVa+waVa):
		maxR = 100*suVa/(suVa+waVa)
		anw = waVa
		ans = suVa

print(anw+ans,ans)

Submission status: Wrong Answer

Solution code:
def maxValue(a,b,v):
	for i in range(v,-1,-1):
		for j in range(v//a+1):
			if (i-a*j)%b==0:
				return i

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

waVa = maxValue(a*100,b*100,f)
suVa = 0
maxR = 0

anw = waVa
ans = suVa

while 1:
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa == 0:
		break
	if maxR<100*suVa/(suVa+waVa):
		maxR = 100*suVa/(suVa+waVa)
		anw = waVa
		ans = suVa

print(anw+ans,ans)

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				#print(j,k//b)
				return i
	return -1

a,b,c,d,e,f = readInts()

waVa = maxValue(a*100,b*100,f*(e//100+1))
suVa = maxValue(c,d,min(f-waVa,waVa*e//100))

maxR = 100*suVa/(suVa+waVa)
anw = 0
ans = 0

while 1:
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa<0 or suVa<0:
		continue
	if waVa == 0:
		break
	if maxR<100*suVa/(suVa+waVa):
		maxR = 100*suVa/(suVa+waVa)
		anw = waVa
		ans = suVa

print(anw+ans,ans)

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				#print(j,k//b)
				return i
	return -1

a,b,c,d,e,f = readInts()

waVa = maxValue(a*100,b*100,f*(e//100+1))
suVa = maxValue(c,d,min(f-waVa,waVa*e//100))

maxR = 100*suVa/(suVa+waVa)
anw = 0
ans = 0

while 1:
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa == 0:
		break
	if maxR<100*suVa/(suVa+waVa):
		maxR = 100*suVa/(suVa+waVa)
		anw = waVa
		ans = suVa

print(anw+ans,ans)

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				#print(j,k//b)
				return i
	return -1

a,b,c,d,e,f = readInts()

waVa = maxValue(a*100,b*100,f*(e//100+1))
suVa = maxValue(c,d,f-waVa)

maxR = 100*suVa/(suVa+waVa)
anw = 0
ans = 0

while 1:
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa == 0:
		break
	if maxR<100*suVa/(suVa+waVa):
		maxR = 100*suVa/(suVa+waVa)
		anw = waVa
		ans = suVa

print(anw+ans,ans)

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				#print(j,k//b)
				return i
	return -1

a,b,c,d,e,f = readInts()

waVa = maxValue(a*100,b*100,f*(e//100+1))
suVa = maxValue(c,d,f-waVa)


maxR = 100*suVa/(suVa+waVa)
anw = 0
ans = 0

while 1:
	
	
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa == 0:
		break
	if maxR<100*suVa/(suVa+waVa):
		maxR = 100*suVa/(suVa+waVa)
		anw = waVa
		ans = suVa
	


print(anw+ans,ans)

Submission status: Wrong Answer

Solution code:
from math import floor
def main():
    a, b, c, d, e, f = map(int, input().split())
    water_max = floor(f / (100 + e) * 100)
    sugar_max = floor(f / (100 + e) * e)
    a_max = floor(water_max / a / 100)
    b_max = floor(water_max / b / 100)
    c_max = floor(sugar_max / c)
    d_max = floor(sugar_max / d)
    water_pattern = []
    for iw1 in range(0, a_max + 1):
        for iw2 in range(0, b_max + 1):
            t_water = iw1 * a * 100 + iw2 * b * 100
            if t_water <= water_max:
                water_pattern.append(t_water)

    sugar_pattern = []
    for is1 in range(0, c_max + 1):
        for is2 in range(0, d_max + 1):
            t_sugar = is1 * c + is2 * d
            if t_sugar <= sugar_max:
                sugar_pattern.append(t_sugar)

    water_pattern.sort(reverse=True)
    sugar_pattern.sort(reverse=True)

    noudo_max = 0
    ans_water = 0
    ans_sugar = 0
    for ewp in water_pattern:
        for esp in sugar_pattern:
            if ewp == 0:
                continue
            else:
                ryou = ewp + esp
                noudo =  floor(esp / ewp * 100)
                if noudo <= e and ryou <= f:
                    if noudo > noudo_max:
                        ans_water = ewp
                        ans_sugar = esp
    print(ans_water + ans_sugar, ans_sugar)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int,input().split())
wa = []
for ia in range(30):
    for ib in range(30):
        if 100*(ia*a+ib*b) <= f and not 100*(ia*a+ib*b) in wa:
            wa.append(ia*a+ib*b)

msu = [0 for i in range(len(wa))]
mc = 0.0
mci = 0
for i,w in enumerate(wa):
    for ic in range(1501):
        for id in range(1501):
            if ic*c+id*d > e*w:
                break
            if ic*c+id*d+w*100 > f:
                break
            if msu[i] < ic*c+id*d:
                msu[i] = ic*c+id*d
                if mc < (ic*c+id*d)/(ic*c+id*d+w*100):
                    mc = (ic*c+id*d)/(ic*c+id*d+w*100)
                    mci = i

print(wa[mci]*100+msu[mci],msu[mci])

Submission status: Wrong Answer

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

def calc(a, b):
    if a == 0 or b == 0: return -1
    return 100 * b / (a + b)
ans = (0, 0)
tmp = 0
ret = set()
for i in range(3001):
    for j in range(3001):
        water = i * A * 100 + j * B * 100
        if 1 > water or water > F: break
        for k in range((F-water)//C+1):
            for l in range((F-water)//D+1):
                suger = k * C + l * D
                if water + suger > F: break
                if water * E // 100 < suger: break
                t = calc(water, suger)
                ret.add((t, water+suger, suger))
                if tmp <= t:
                    tmp = t
                    ans = (water+suger, suger)

ret = list(ret)
ret.sort(reverse=True)
print(*ans)