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 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
for i in range(F//100+1):
    for j in range(F//100+1):
        water = i * 100 + j * 100
        if 1 > water or water > F: break
        for k in range(F//C+1):
            for l in range(F//D+1):
                suger = k * C + l * D
                if water + suger > F: break
                if water * E // 100 < suger: break
                t = calc(water, suger)
                if tmp <= t:
                    tmp = t
                    ans = (water+suger, suger)

print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    max_deisity = 100 * E / (100 + E)
    MAX = 0
    W = 0
    S = 0
    for a in range(F // (100 * A) + 1):
        rest1 = F - a * A * 100
        for b in range(rest1 // (100 * B) + 1):
            if a == 0 and b == 0:
                continue

            water = a * A * 100 + b * B * 100
            rest2 = F - water
            for c in range(rest2 // C + 1):
                rest3 = rest2 - C * c
                for d in range(rest3 // D + 1):
                    sugar = C * c + D * d

                    if water + sugar > F:
                        continue

                    density = 100 * sugar / (water + sugar)
                    if max_deisity < density:
                        continue

                    if density > MAX:
                        MAX = density
                        W = water
                        S = sugar

    print(W + S, S)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    MAX = 0
    W = 0
    S = 0
    for a in range(F // (100 * A) + 1):
        rest1 = F - a * A * 100
        for b in range(rest1 // (100 * B) + 1):
            if a == 0 and b == 0:
                continue

            water = a * A * 100 + b * B * 100
            rest2 = F - water
            for c in range(rest2 // C + 1):
                rest3 = rest2 - C * c
                for d in range(rest3 // D + 1):
                    sugar = C * c + D * d

                    if water + sugar > F:
                        continue

                    if water * E < sugar * 100:
                        continue

                    density = 100 * sugar / (water + sugar)
                    if density > MAX:
                        MAX = density
                        W = water
                        S = sugar

    print(W + S, S)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    MAX = 0
    W = 0
    S = 0
    for a in range(F // (100 * A) + 1):
        rest1 = F - a * A * 100
        for b in range(rest1 // (100 * B) + 1):
            if a == 0 and b == 0:
                continue

            water = a * A * 100 + b * B * 100
            rest2 = F - water
            for c in range(rest2 // C + 1):
                rest3 = rest2 - C * c
                for d in range(rest3 // D + 1):
                    sugar = C * c + D * d

                    if water + sugar > F:
                        continue

                    if water * E / 100 < sugar:
                        continue

                    density = 100 * sugar / (water + sugar)
                    if density > MAX:
                        MAX = density
                        W = water
                        S = sugar

    print(W + S, S)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c,d,e,f=map(int,readline().split())

    w=[]
    for i in range(0,f+1,100):
        for j in range(0,f+1,100):
            n=a*i+b*j
            if n<=f:
                w.append(n)
    w.sort()

    s=[]
    for i in range(f+1):
        for j in range(f+1):
            n=c*i+d*j
            if n<=f:
                s.append(n)
    s.sort()

    cnt=0
    res=[0,0]
    for x in w:
        for y in s:
            if x+y>f:
                break

            ma=x//100*e
            if y>ma:
                continue
            
            if x+y!=0 and cnt<100*y/(x+y):
                cnt=100*y/(x+y)
                res=[x+y,y]

    print(*res)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c,d,e,f=map(int,readline().split())

    w=[]
    for i in range(0,f+1,100):
        for j in range(0,f+1,100):
            n=a*i+b*j
            if n<=f:
                w.append(n)
    w.sort()

    s=[]
    for i in range(f+1):
        for j in range(f+1):
            n=c*i+d*j
            if n<=f:
                s.append(n)
    s.sort()

    cnt=0
    res=[]
    for x in w:
        for y in s:
            if x+y>f:
                break

            ma=x//100*e
            if y>ma:
                continue
            
            if x+y!=0 and cnt<100*y/(x+y):
                cnt=100*y/(x+y)
                res=[x+y,y]

    print(*res)
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

water = []
sugar = []
for i in range(0,1000):
    for j in range(0,1000):
        if (100*i*a + 100*j*b ) <= f:
            water.append(100*i*a + 100*j*b)
        if c*i + d*j <= f:
            sugar.append(c*i+d*j)
        

water = list(set(water))
water.sort()
water.remove(0)
sugar = list(set(sugar))
sugar.sort()

concentration = 0
sgw = 0
sg = 0



x = e/100

for i in water:
    for j in sugar:
        temp = (100 * j) / (i + j)
        if concentration < temp and i + j < f and (i /100)*e  >= j:
           # print(i,j,concentration,temp,i*x)
            sgw = i + j
            sg = j
            concentration = temp
print(sgw,sg)

Submission status: Wrong Answer

Solution code:
def dense(a, b):
	return b / (a+b)

def resolve():
	a, b, c, d, e, f = map(int, input().split())
	ws = set()
	ss = set()
	for i in range(31):
		for j in range(31):
			if a*100*i + b*100*j <= f:
				ws.add(a*100*i + b*100*j)
	for i in range(3001):
		for j in range(3001):
			if c*i + j*d <= f:
				ss.add(c*i + j*d)
	ans_w, ans_s = -1, 0
	lim = e / (100+e)
	for wv in ws:
		for sv in ss:
			if wv + sv > f:
				continue
			if wv + sv == 0:
				continue
			if lim >= dense(wv, sv):
				if dense(ans_w, ans_s) < dense(wv, sv):
					ans_w, ans_s = wv, sv
	print(ans_w + ans_s, ans_s)
resolve()

Submission status: Wrong Answer

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

w=[]
s=[]
for i in range(F):
    for j in range(F):
        a=100*A*i
        b=100*B*j
        if (a+b)>F:
            continue

        w.append(a+b)

for i in range(F):
    for j in range(F):
        c=C*i
        d=D*j
        if (c+d)>F:
            continue
        s.append(c+d)
ans=0.0
l=[100*A,0]
for water in w:
    for sugar in s:
        p=water+sugar
        if p==0:
            continue
        val=sugar/p
        if val<=(E/(100+E)):
            if ans<val:
                ans=val
                l=[p,sugar]

print(*l)

Submission status: Wrong Answer

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

ws = set()
ss = set()
for a in range(0, F+1, A*100):
    for b in range(0, F+1-a, B*100):
        ws.add(a + b)

for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        ss.add(c + d)

mx = 0
ans = 0, 0
for w in ws:
    if w == 0:
        continue
    for s in ss:
        x = s * 100 / w
        if w + s <= F and x <= E and mx < x:
            mx = x
            ans = s + w, s

print(*ans)

Submission status: Wrong Answer

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

mx = -1
ans = 0, 0
for a in range(0, F+1, A*100):
    for b in range(0, F-a+1, B*100):
        if a + b == 0:
            continue

        for c in range(0, F-a-b+1, C):
            for d in range(0, F-a-b-c+1, D):
                x = 100 * (c + d) / (a + b)
                if x <= E and mx < x:
                    mx = x
                    ans = (a + b + c + d), int(x)
print(*ans)

Submission status: Wrong Answer

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

ws = set()
ss = set()
for a in range(0, F+1, A*100):
    for b in range(0, F+1-a, B*100):
        ws.add(a + b)

for c in range(0, F+1, C):
    for d in range(0, F+1-c, D):
        ss.add(c + d)

mx = -1
ans = 0, 0
for w in ws:
    if w == 0:
        continue
    for s in ss:
        x = s * 100 / w
        print(s, w, x, s+w, w + s <= F, x <= E, mx < x)
        if w + s <= F and x <= E and mx < x:
            mx = x
            ans = s + w, s

print(*ans)

Submission status: Wrong Answer

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

    # 水と砂糖それぞれ別で、ありえる候補を出す
    wt = set()
    sg = set()
    for i in range(0, F+1, 100*A):
        for j in range(0, F+1, 100*B):
            if 0 < i + j and i + j <= F:
                wt.add(i + j)
    for i in range(0, F+1, C):
        for j in range(0, F+1, D):
            if 0 < i + j and i + j <= F:
                sg.add(i + j)

    # 水と砂糖の組合せを試す
    ans_t, ans_s = -1, -1
    concent = -1
    for w in wt:
        for s in sg:
            if F < w + s: continue  # 総重量オーバー
            if E * w // 100 < s: continue  # 溶けきらない
            if concent < s / (w + s):
                ans_t, ans_s = w + s, s  # 濃度が高ければ答えを更新
                concent = s / (w + s)

    print('{} {}'.format(ans_t, ans_s))

abc083_c()

Submission status: Wrong Answer

Solution code:
def dense(w, s):
	if w == 0 and s == 0:
		return 0
	return s / (w + s) * 100

def resolve():
	A, B, C, D, E, F = map(int, input().split())
	waters = set()
	sugars = set()

	for i in range(31):
		for j in range(31):
			v = A*i*100 + B*j*100
			if v > F:
				continue
			waters.add(v)
	for i in range(101):
		for j in range(101):
			v = i*C + j*D
			if v > F:
				continue
			sugars.add(v)
	ans_w, ans_s = 0, 0
	for w in waters:
		for s in sugars:
			if w + s > F or s > w//100*E:
				continue
			if dense(w, s) > dense(ans_w, ans_s):
				ans_w, ans_s = w, s
	print(ans_w + ans_s, ans_s)
resolve()

Submission status: Wrong Answer

Solution code:
def dense(w, s):
	if w == 0 and s == 0:
		return 0
	return 100 * s / (w + s)

def resolve():
	A, B, C, D, E, F = map(int, input().split())
	waters = set()
	sugars = set()

	for i in range(31):
		for j in range(31):
			v = A*i*100 + B*j*100
			if v > F:
				continue
			waters.add(v)
	for i in range(101):
		for j in range(101):
			v = i*C + j*D
			if v > F:
				continue
			sugars.add(v)
	ans_w, ans_s = 0, 0
	for w in waters:
		for s in sugars:
			if w + s > F or s > w//100*E:
				continue
			if dense(w, s) > dense(ans_w, ans_s):
				ans_w, ans_s = w, s
	print(ans_w + ans_s, ans_s)
resolve()

Submission status: Wrong Answer

Solution code:
def dense(w, s):
	if s == 0:
		return 0

	return 100*s // (w+s)

def resolve():
	a, b, c, d, e, f = map(int, input().split())
	water, sugar = 0, 0
	for i in range(31):
		for j in range(31):
			for k in range(101):
				for l in range(101):
					w = i * a * 100 + j * b * 100
					s = c*k + d*l
					if w//100*e < s or w + s > f:
						continue
					if dense(w, s) > dense(water, sugar):
						water, sugar = w+s, s
resolve()

Submission status: Wrong Answer

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,D,E,F = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = [F,0]
    for a in range(0,F+1,100*A):
        for b in range(0,F+1,100*B):
            if a+b == 0:
                break
            for c in range(0,F+1,C):
                for d in range(0,F+1,D):
                    if a+b+c+d>F:
                        break
                    elif (c+d)/(a+b)>E/100:
                        break
                    else:
                        if cnt[1]/cnt[0] < (c+d)/(a+b+c+d):
                            cnt[0] = a+b+c+d
                            cnt[1] = c+d
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt[0],cnt[1])

Submission status: Wrong Answer

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,D,E,F = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = [F,0]
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if A*a+B*b == 0:
                break
            for c in range(F//C+1):
                for d in range(F//D+1):
                    if 100*A*a+100*B*b+C*c+D*d>F:
                        break
                    elif (C*c+D*d)/(A*a+B*b)>E:
                        break
                    else:
                        if cnt[1]/cnt[0] < (C*c+D*d)/(100*A*a+100*B*b+C*c+D*d):
                            cnt[0] = 100*A*a+100*B*b+C*c+D*d
                            cnt[1] = C*c+D*d
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt[0],cnt[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = list(map(int,input().split()))
dp = [False]*3001
for i in range(0,3001,c):
    for j in range(0,3001,d):
        if i + j < 3001:
            dp[i+j] = True

noudo = 0
mizu = 100*a
sato = 0

for i in range(0,f+1,100*a):
    for j in range(0,f+1,100*b):
        if i + j > f:continue
        genkai = min(f-i-j,e * (i+j) // 100 )
        for k in range(genkai,-1,-1):
            if dp[k]:
                if noudo < (k * 100) // (i+j+dp[k]):
                    noudo = (k*100) // (i+j+dp[k])
                    mizu = i+j
                    sato = k
                break

print(mizu + sato,sato)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = list(map(int,input().split()))
dp = [False]*3001
for i in range(0,3001,c):
    for j in range(0,3001,d):
        if i + j < 3001:
            dp[i+j] = True

noudo = 0
mizu = 100*a
sato = 0

for i in range(100*a,f+1,100*a):
    for j in range(0,f+1,100*b):
        if i + j > f:continue
        genkai = min(f-i-j,e * (i+j) // 100 )
        for k in range(genkai,-1,-1):
            if dp[k]:
                if noudo < (k * 100) // (i+j+dp[k]):
                    noudo = (k*100) // (i+j+dp[k])
                    mizu = i+j
                    sato = k
                break

print(mizu + sato,sato)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = list(map(int,input().split()))
dp = [False]*3001
for i in range(0,3001,c):
    for j in range(0,3001,d):
        if i + j < 3001:
            dp[i+j] = True

noudo = 0
mizu = 0
sato = 0

for i in range(0,f+1,100*a):
    for j in range(0,f+1,100*b):
        if i + j > f:continue
        genkai = min(f-i-j,e * (i+j) // 100 )
        for k in range(genkai,0,-1):
            if dp[k]:
                if noudo < (k * 100) // (i+j+dp[k]):
                    noudo = (k*100) // (i+j+dp[k])
                    mizu = i+j
                    sato = k
                break

print(mizu + sato,sato)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = list(map(int,input().split()))
dp = [False]*3001
for i in range(0,3001,c):
    for j in range(0,3001,d):
        if i + j < 3001:
            dp[i+j] = True

noudo = 0
mizu = 0
sato = 0

for i in range(0,f+1,100*a):
    for j in range(0,f+1,100*b):
        if i + j > f:continue
        genkai = min(f-i-j,e * (i+j) // 100 )
        for k in range(genkai,-1,-1):
            if dp[k]:
                if noudo < (k * 100) // (i+j+dp[k]):
                    noudo = (k*100) // (i+j+dp[k])
                    mizu = i+j
                    sato = k
                break

print(mizu + sato,sato)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
ans_per, ans_w, ans_s = 0,0,0
for i in range(f//(100*a) + 1):
  for j in range((f-100*i)//(100*b) + 1):
    if i == j == 0:
      continue
    w = i*a*100 + j*b*100
    r = min(f-w, w//100 * e)
    for x in range(r//c + 1):
      for y in range((r-x*c)//d + 1):
        s = x*c + y*d
        if s / w > ans_per:
          ans_per = s/w
          ans_w = w
          ans_s = s
print('{} {}'.format(ans_w+ans_s, ans_s))

Submission status: Wrong Answer

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

water = set()
sugar = set()

for i in range(F+1):
    for j in range(F+1-A):
        w = (100*A*i) + (100*B*j)
        if w <= F:
            water.add(w)

for i in range(F+1):
    for j in range(F+1):
        s = (i*C)+(j*D)
        if s <= F:
            sugar.add(s)

print(water, sugar)
per = -10000
for w in water:
    for s in sugar:
        ws = w+s
        # 砂糖水の質量合計はFg以下 and 砂糖が溶け残らない
        if (0 < ws <= F) and (s <= w*E // 100):
            if s/(ws) > per:
                per = s/(ws)
                ans = ws, s

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

Submission status: Wrong Answer

Solution code:



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

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a//gcd(a, b)*b

def sub(s, c, d):
    # k3*c + k4*d でsに近い値を作る
    l = lcm(c, d)
    v = s % l
    lst = [False] * l
    for k in range(l//c):
        for kk in range(l//d):
            if k*c+kk*d<l:
                lst[k*c+kk*d] = True
    while lst[v]==False:
        v-=1
    return (s//l)*l + v
    
best = (0, 100*a, 0)
k1 = 0
while True:
    k2 = 0
    while True:
        w = 100*k1*a + 100*k2*b
        if w==0:
            k2 += 1
            continue
        if w>f:
            break
        s = min(f - w, int(w*e / 100))
        val = sub(s, c, d)
#         print(s, c, d, val)
        if best[0] < val/(w+val):
            best = (val/(w+val), w, val)
        k2 += 1
    k1+=1
    if 100*k1*a>f:
        break
print(best[1]+best[2], best[2], sep=" ")

Submission status: Wrong Answer

Solution code:


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

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a//gcd(a, b)*b

def sub(s, c, d):
    # k3*c + k4*d でsに近い値を作る
    l = lcm(c, d)
    v = s % l
    lst = [False] * l
    for k in range(l//c):
        for kk in range(l//d):
            if k*c+kk*d<l:
                lst[k*c+kk*d] = True
    while lst[v]==False:
        v-=1
    return (s//l)*l + v
    
best = (0, 100*a, 0)
k1 = 0
while True:
    k2 = 0
    while True:
        w = 100*k1*a + 100*k2*b
        if w==0:
            k2 += 1
            continue
        if w>f:
            break
        s = min(f - w, int(w*e / 100))
        val = sub(s, c, d)
#         print(s, c, d, val)
        if best[0] < val/w:
            best = (val/(w+val), w, val)
        k2 += 1
    k1+=1
    if 100*k1*a>f:
        break
print(best[1]+best[2], best[2], sep=" ")

Submission status: Wrong Answer

Solution code:

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

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a//gcd(a, b)*b

def sub(s, c, d):
    # k3*c + k4*d でsに近い値を作る
    l = lcm(c, d)
    v = s % l
    lst = [False] * l
    for k in range(l//c):
        for kk in range(l//d):
            if k*c+kk*d<l:
                lst[k*c+kk*d] = True
    while lst[v]==False:
        v-=1
    return (s//l)*l + v
    
best = (0, 100*a, 0)
k1 = 0
while True:
    k2 = 0
    while True:
        w = 100*k1*a + 100*k2*b
        if w==0:
            k2 += 1
            continue
        if w>f:
            break
        s = min(f - w, int(w*e / 100))
        val = sub(s, c, d)
#         print(s, c, d, val)
        if best[0] < val/w:
            best = (val/w, w, val)
        k2 += 1
    k1+=1
    if 100*k1*a>f:
        break
print(best[1]+best[2], best[2], sep=" ")

Submission status: Wrong Answer

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

waterL=[]
ac=0
while a*100*ac<=f:
    bc=0
    while a*100*ac+b*100*bc<=f:
        waterL.append(a*100*ac+b*100*bc)
        bc += 1
    ac += 1
waterL.remove(0)
ma=0
ms=0
mw=0
for w in waterL:
    lim=w/100*e
    cc=0
    while c*cc<=lim and c*cc+w<=f:
        dc=(lim-c*cc)//d
        s=c*cc+d*dc
        cc += 1
        if s+w<=f:
            per=s/(w+s)
            if per>=ma:
                ma=per
                ms=s
                mw=w
print(int(ms+mw),int(ms))

Submission status: Wrong Answer

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

waterL=[]
ac=0
while a*100*ac<=f:
    bc=0
    while a*100*ac+b*100*bc<=f:
        waterL.append(a*100*ac+b*100*bc)
        bc += 1
    ac += 1
waterL.remove(0)
ma=0
ms=0
mw=0
for w in waterL:
    lim=w/100*e
    cc=0
    while c*cc<=lim and c*cc+w<=f:
        dc=(lim-c*cc)//d
        s=c*cc+d*dc
        cc += 1
        if s+w<=f:
            per=s/(w+s)
            if per>ma:
                ma=per
                ms=s
                mw=w
print(int(ms+mw),int(ms))

Submission status: Wrong Answer

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

#A,B　水
#C,D satou
#E 溶解度　F 容量

V=0
node=0
total=0
sugar=0

for a in range(F//(100*A)+1):
    for b in range((F-100*A*a)//(100*B)+1):
        v=F-100*A*a-100*B*b
        for c in range(v//C+1):
            v2=v-c*C
            for d in range(v2//D+1):
                v3=v2-d*D
                if v3<0:
                    continue
                if a==0 and b==0:
                    continue
                if (c*C+d*D)/(a*A+b*B)>E:
                    continue
                nownode=100*(c*C+d*D)/((c*C+d*D)+(a*A+b*B)*100)
                if nownode>node:
                    node=nownode
                    total=F-v3
                    sugar=(c*C+d*D)

print(total, sugar)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
xmax = 1
kmax = 0
for n in range(31):
    for m in range(31):
        x = 100*(n*A+m*B)
        ymax = min((n*A+m*B)*E,F-100*(n*A+m*B))
        for k in range(ymax,ymax-C-1,-1):
            t = 0
            flag = 0
            while k-t*D>=0:
                if (k-t*D)%C==0:
                    flag = 1
                    break
                t += 1
            if flag==1:
                if kmax*(x+k)<k*(xmax+kmax):
                    xmax = x
                    kmax = k
print(xmax+kmax,kmax)

Submission status: Wrong Answer

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

total = 1
sugar = 0

for a in range(F// (100 * A) + 1):
    for b in range((F - (100 * a)) // (100 * B) + 1):
        tmp_water = 100 * (A * a + B * b)
        if tmp_water == 0:
            continue
        
        maxC = min(tmp_water // 100 * E, F - tmp_water) #溶ける量とビーカーの質量の問題
        
        if maxC <= 0:
            continue

        # print (tmp_water)

        for c in range(0, maxC + 1, C): #Cグラム刻みで増やす
            # print ('c', c)
            left = maxC - c
            d = (left // D) * D
            tmp_sugar = c + d
            tmp_total = tmp_sugar + tmp_water
            if sugar * tmp_total < tmp_sugar * total:
                total = tmp_total
                sugar = tmp_sugar

print (total, sugar)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,d,e,f = inpl()
mx = 0
res = 0
ans = 0
for i in range(40):
    for j in range(40):
        water = 100*a*i + 100*b*j
        if water == 0:
            continue
        for k in range(300):
            for l in range(300):
                sugar = c*k + d*l
                if water+sugar > f or sugar > (i+j)*e:
                    continue
                if sugar/(water+sugar) >= mx:
                    mx = sugar/(water+sugar)
                    res = water+sugar
                    ans = sugar
print(res,ans)

Submission status: Wrong Answer

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

dp = [-1] * (F + 1)  # dp[f] = sugar
dp[0] = 0

for f in range(F + 1):
    if A + f <= F:
        dp[A + f] = max(dp[A + f], dp[f])
    if B + f <= F:
        dp[B + f] = max(dp[B + f], dp[f])
    if C + f <= F and dp[f] >= 0:
        water = f - dp[f]
        maxSugar = (water // 100) * E
        if dp[f] + C <= maxSugar:
            dp[C + f] = max(dp[C + f], dp[f] + C)
    if D + f <= F and dp[f] >= 0:
        water = f - dp[f]
        maxSugar = (water // 100) * E
        if dp[f] + D <= maxSugar:
            dp[D + f] = max(dp[D + f], dp[f] + D)

ans = (0, 0)
mx = 0
for f in range(1, F + 1):
    if mx < 100 * dp[f] / f:
        mx = 100 * dp[f] / f
        ans = (f, dp[f])
print(*ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,d,e,f = inpl()
mx = 0
res = 0
ans = 0
for i in range(30):
    for j in range(30):
        water = 100*i + 100*j
        if water == 0:
            continue
        for k in range(300):
            for l in range(300):
                sugar = c*k + d*l
                if water+sugar > f or sugar > (i+j)*e:
                    continue
                if sugar/(water+sugar) >= mx:
                    mx = sugar/(water+sugar)
                    res = water+sugar; 
                    ans = sugar
print(res,ans)

Submission status: Wrong Answer

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

max_nodo = 0
ans = [0, 0]
for i in range(30//a+1):
    for j in range(30//b+1):
        mizu = 100*i*a + 100*j*b
        if mizu > f: break
        if mizu == 0: continue
        maxi = (i*a + j*b) * e
        for k in range(maxi//c+1):
            for l in range(maxi//d+1):
                sato = c*k + d*l
                if mizu+sato > f: break
                if sato > maxi: break
                nodo = sato / (mizu+sato)
                if nodo > max_nodo:
                    max_nodo = nodo
                    ans = [mizu+sato, sato]

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

Submission status: Wrong Answer

Solution code:

def dense(w, s):
	if s == 0:
		return 0

	return 100*s // (w+s)

def resolve():
	a, b, c, d, e, f = map(int, input().split())
	water, sugar = 0, 0
	for i in range(40):
		for j in range(40):
			for k in range(40):
				for l in range(40):
					cap = i*a*e + j*b*e
					w = i * a * 100 + j * b * 100
					s = c*k + d*l
					if cap >= s and w + s <= f:
						if dense(w, s) > dense(water, sugar):
							water, sugar = w+s, s
	print(water, sugar)


resolve()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, readline().rstrip().split())
    X = set()
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if 100 * a * A + 100 * b * B <= F:
                X.add(100 * a * A + 100 * b * B)
    # X.remove(0)

    Y = set()
    for c in range(F//C+1):
        for d in range(F//D+1):
            if c * C + d * D <= F/2:
                Y.add((c * C + d * D))

    ans = (0, 0)
    max_dens = 0
    for x in X:
        for y in Y:
            if x + y == 0:
                continue
            if x + y > F:
                continue
            if y * 100 <= x * E:
                dens = y/(x+y)
                if dens > max_dens:
                    ans = (x+y, y)
                    max_dens = dens
    print(*ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def main():
    A, B, C, D, E, F = map(int, readline().rstrip().split())
    X = set()
    for a in range(F//(100*A)+1):
        for b in range(F//(100*B)+1):
            if 100 * a * A + 100 * b * B <= F:
                X.add(100 * a * A + 100 * b * B)
    X.remove(0)

    Y = set()
    for c in range(F//C+1):
        for d in range(F//D+1):
            if c * C + d * D <= F/2:
                Y.add((c * C + d * D))

    ans = (0, 0)
    max_dens = 0
    for x in X:
        for y in Y:
            if x + y > F:
                continue
            if y * 100 <= x * E:
                dens = y/(x+y)
                if dens > max_dens:
                    ans = (x+y, y)
                    max_dens = dens
    print(*ans)

if __name__ == '__main__':
    main()