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:
A,B,C,D,E,F = map(int,input().split())
solve = E/(100+E)
ans = [0,0,0]
for i in range(int(F//100//A)+1):
    for j in range(int((F-A*100*i)//100//B)+1):
        for k in range(int((F-A*100*i-B*100*j)//C)+1):
            for l in range(int((F-A*100*i-B*100*j-C*k)//D)+1):
                if  i!=0 or j!=0:
                    can = (C*k+D*l)/(A*100*i+B*100*j+C*k+D*l)
                    if solve>=can>ans[0]:
                        
                        ans[0],ans[1],ans[2] = can,A*100*i+B*100*j+C*k+D*l,C*k+D*l

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

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
Water,Sugar=100,0
for q in range((F//(100*B))+1):
    limit=F-100*B*q
    for p in range((limit//(100*A))+1):
        limit-=100*A*p
        if p==0 and q==0:pass
        else:
            for s in range((limit//D)+1):
                limit-=D*s
                for r in range((limit//C)+1):
                    if (A*p+B*q)*E<C*r+D*s:pass
                    else:
                        if (C*r+D*s)/(100*(A*p+B*q)+(C*r+D*s))>=Sugar/(Water+Sugar):Water,Sugar=(A*p+B*q)*100,C*r+D*s
                        else:pass

print(Water+Sugar,Sugar)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
ansS = 0
ansT = 0
rate = 0
for a in range(F // (A*100)+1):
    di_a = F - A*a*100
    for b in range(di_a // (B*100) + 1):
        di_b = di_a - B*b*100
        for c in range(di_b//C+1):
            di_c = di_b - c*C
            for d in range(di_c //D+1):
                if (a+b != 0 and E*(a*A+b*B) >= c*C+d*D):
                    total = 100*(A*a+B*b)+c*C+d*D
                    sugers = c*C+d*D
                    if(rate < sugers/total and total <= F):
                        rate = sugers/total
                        ansT = total
                        ansS = sugers

print(ansT, ansS)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
ansS = 0
ansT = 0
rate = 0
for a in range(F // (A*100)+1):
    di_a = F - A*a*100
    for b in range(di_a // (B*100) + 1):
        di_b = di_a - B*b*100
        for c in range(di_b//C+1):
            di_c = di_b - c*C
            for d in range(di_c //D+1):
                if (a+b != 0 and E*(a*A+b*B) >= c*C+d*D):
                    total = 100*(A*a+B*b)+c*C+d*D
                    sugers = c*C+d*D
                    if(rate < sugers / total):
                        ansT = total
                        ansS = sugers
print(ansT, ansS)

Submission status: Wrong Answer

Solution code:
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 0;
ans_s = 0;
for i in range(0,f,100*a) :
	for j in range(0,f,100*b) :
		#if 100 * a * i + 100 * b * j <= f :
			for k in range(0, f - i - j,c) :
				for l in range(0, f - i - j,d) :
					if i != 0 or j != 0 or k != 0 or l != 0 :
						#print(i,j,k,l,100*( k + l )//( i + j + k + l ));
						if i+j+k+l <= f and  k + l <= e * ( i + j )//100 :
							if 100*( k + l )/( i + j + k + l ) > ans :
								ans = 100 *( k + l )/( i + j + k + l );
								ans_w = i + j;
								ans_s = k + l;
print(ans_w+ans_s,ans_s);

Submission status: Wrong Answer

Solution code:
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 0;
ans_s = 0;
for i in range(0,f,100*a) :
	for j in range(0,f,100*b) :
		#if 100 * a * i + 100 * b * j <= f :
			for k in range(0, f - i - j,c) :
				for l in range(0, f - i - j,d) :
					if i != 0 or j != 0 or k != 0 or l != 0 :
						#print(i,j,k,l,100*( k + l )//( i + j + k + l ));
						if i+j+k+l <= f and  k + l <= e * ( i + j )//100 :
							if 100*( k + l )//( i + j + k + l ) > ans :
								ans = 100 *( k + l )//( i + j + k + l );
								ans_w = i + j;
								ans_s = k + l;
print(ans_w+ans_s,ans_s);

Submission status: Wrong Answer

Solution code:
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 0;
ans_s = 0;
for i in range(0,f,100*a) :
	for j in range(0,f,100*b) :
		#if 100 * a * i + 100 * b * j <= f :
			for k in range(0, f - i - j,c) :
				for l in range(0, f - i - j,d) :
					if i+j+k+l <= f and  k + l <= e * ( i + j )//100 :
						if i != 0 or j != 0 or k != 0 or l != 0 :
							if 100*(c * k + d * l )//( 100 * a * i + 100 * b * j + c * k + d * l ) > ans :
								ans = 100 *(c * k + d * l )//( 100 * a * i + 100 * b * j + c * k + d * l );
								ans_w = 100 * a * i + 100 * b * j;
								ans_s = c * k + d * l;
print(ans_w+ans_s,ans_s);

Submission status: Wrong Answer

Solution code:
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 0;
ans_s = 0;
for i in range(0,f//100) :
	for j in range(0,f//100) :
		#if 100 * a * i + 100 * b * j <= f :
			for k in range(0, f - 100 * a * i - 100 * b * j) :
				for l in range(0, f - 100 * a * i - 100 * b * j) :
					x = 100 * a * i + 100 * b * j + c * k + d * l 
					if x <= f and  c * k + d * l <= e * ( a * i + b * j ) :
						if i != 0 or j != 0 or k != 0 or l != 0 :
							if 100*(c * k + d * l )//( 100 * a * i + 100 * b * j + c * k + d * l ) > ans :
								ans = 100 *(c * k + d * l )//( 100 * a * i + 100 * b * j + c * k + d * l );
								ans_w = 100 * a * i + 100 * b * j;
								ans_s = c * k + d * l;
print(ans_w+ans_s,ans_s);

Submission status: Wrong Answer

Solution code:
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 0;
ans_s = 0;
for i in range(0,f//100) :
	for j in range(0,f//100) :
		#if 100 * a * i + 100 * b * j <= f :
			for k in range(0, f - 100 * a * i - 100 * b * j) :
				for l in range(0, f - 100 * a * i - 100 * b * j) :
					if 100 * a * i + 100 * b * j + c * k + d * l <= f and  c * k + d * l <= e * ( a * i + b * j ) :
						if i != 0 or j != 0 or k != 0 or l != 0 :
							if 100*(c * k + d * l )//( 100 * a * i + 100 * b * j + c * k + d * l ) > ans :
								ans = 100 *(c * k + d * l )//( 100 * a * i + 100 * b * j + c * k + d * l );
								ans_w = 100 * a * i + 100 * b * j;
								ans_s = c * k + d * l;
print(ans_w+ans_s,ans_s);

Submission status: Wrong Answer

Solution code:
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 0;
ans_s = 0;
for i in range(0,f//100) :
	for j in range(0,f//100) :
		#if 100 * a * i + 100 * b * j <= f :
			for k in range(0, f - 100 * a * i - 100 * b * j,c) :
				for l in range(0, f - 100 * a * i - 100 * b * j,d) :
					if 100 * a * i + 100 * b * j + c * k + d * l <= f and  c * k + d * l <= e * ( a * i + b * j ) :
						if i != 0 or j != 0 or k != 0 or l != 0 :
							if 100*(c * k + d * l )//( 100 * a * i + 100 * b * j + c * k + d * l ) > ans :
								ans = 100 *(c * k + d * l )//( 100 * a * i + 100 * b * j + c * k + d * l );
								ans_w = 100 * a * i + 100 * b * j;
								ans_s = c * k + d * l;
print(ans_w+ans_s,ans_s);

Submission status: Wrong Answer

Solution code:
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 0;
ans_s = 0;
for i in range(0,f//100) :
	for j in range(0,f//100) :
		if 100 * a * i + 100 * b * j <= f :
			for k in range(0, f - 100 * a * i - 100 * b * j) :
				for l in range(0, f - 100 * a * i - 100 * b * j) :
					if 100 * a * i + 100 * b * j + c * k + d * l <= f and  c * k + d * l <= e * ( a * i + b * j ) :
						if i != 0 or j != 0 or k != 0 or l != 0 :
							if 100*(c * k + d * l )/( 100 * a * i + 100 * b * j + c * k + d * l ) > ans :
								ans = 100 *(c * k + d * l )/( 100 * a * i + 100 * b * j + c * k + d * l );
								ans_w = 100 * a * i + 100 * b * j;
								ans_s = c * k + d * l;
print(ans_w+ans_s,ans_s);

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
lim = int(E / (100+E))
ansS = 0
ansW = 0
ns = 0
for a in range(31):
    for b in range(31):
        for c in range(100):
            for d in range(100):
                sugers = c*C + d*D
                waters = (a*A+b*B)*100
                totalWeight = waters + sugers
                if(totalWeight > F or waters == 0):
                    break
                if(waters*E/100 < sugers):
                    break
                if(ns < sugers/totalWeight):
                    ns = sugers/totalWeight
                    ansS = sugers
                    ansW = totalWeight
                    #print("waters:", waters, " sugers:", sugers, " totalWeight:", totalWeight)
                    #print()

print(ansW, ansS)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
lim = int(E / (100+E))
ansS = 0
ansW = 0
ns = 0
for a in range(31):
    for b in range(31):
        for c in range(100):
            for d in range(100):
                sugers = c*C + d*D
                waters = (a*A+b*B)*100
                totalWeight = waters + sugers
                if(totalWeight >= F or waters == 0):
                    break
                if(waters*E/100 <= sugers):
                    break
                if(ns < sugers/totalWeight):
                    ns = sugers/totalWeight
                    ansS = sugers
                    ansW = totalWeight
                    #print("waters:", waters, " sugers:", sugers, " totalWeight:", totalWeight)
                    #print()

print(ansW, ansS)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split())
lim = int(E / (100+E))
ansS = 0
ansW = 0
ns = 0
for a in range(31):
    for b in range(31):
        for c in range(100):
            for d in range(100):
                sugers = c*C + d*D
                waters = (a*A+b*B)*100
                totalWeight = waters + sugers
                if(totalWeight >= F or waters == 0):
                    break
                if(waters*E/100 < sugers):
                    break
                if(ns < sugers/totalWeight):
                    ns = sugers/totalWeight
                    ansS = sugers
                    ansW = totalWeight
                    #print("waters:", waters, " sugers:", sugers, " totalWeight:", totalWeight)
                    #print()

print(ansW, ansS)

Submission status: Wrong Answer

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

dil=0
ans=(0,0)
for i in range(F//(A*100)+1):
    F_remainA=F-i*A*100
    for j in range(F_remainA//B*100+1):
        F_remainB=F_remainA-j*B*100   
        for k in range(F_remainB//C+1):
            F_remainC=F_remainB-k*C
            for l in range(F_remainC//D+1):
                if i+j!=0 and k+l!=0:
                    if (k*C+l*D)/(i*A*100+j*B*100+k*C+l*D) > dil and (k*C+l*D)/(i*A+j*B)<=E:
                        dil=(k*C+l*D)/(i*A*100+j*B*100+k*C+l*D)
                        ans=(100*(i*A+j*B)+k*C+l*D, k*C+l*D)

print(*ans)

Submission status: Wrong Answer

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

dil=0
ans=(0,0)
for i in range(F//(A*100)+1):
    F_remain=F-i*A*100
    for j in range(F_remain//B*100+1):
        F_remain=F_remain-j*B*100   
        for k in range(F_remain//C+1):
            F_remain=F_remain-k*C
            for l in range(F_remain//D+1):
                if i+j!=0 and k+l!=0:
                    if (k*C+l*D)/(i*A*100+j*B*100+k*C+l*D) > dil and (k*C+l*D)/(i*A+j*B)<=E:
                        dil=(k*C+l*D)/(i*A*100+j*B*100+k*C+l*D)
                        ans=(100*(i*A+j*B)+k*C+l*D, k*C+l*D)

print(*ans)

Submission status: Wrong Answer

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

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

max_density = 0
max_total = 0
max_sugar = 0
for i in range(F // 100):
    for j in range(F // 100):
        if i == 0 and j == 0:
            continue

        water = 100*A*i + 100*B*j
        if water > F:
            break

        left = F - water
        sugar_limit = min((A*i+B*j)*E, F - water)

        msugar = 0
        for k in range(sugar_limit // C + 1):
            for l in range(sugar_limit // D + 1):
                sugar = C * k + D * l
                if sugar > sugar_limit:
                    break
                if sugar > msugar:
                    msugar = sugar

        density = 100 * msugar / (msugar + water)
        if density > max_density:
            max_density = density
            max_total = msugar + water
            max_sugar = msugar

print(max_total, max_sugar)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 濃度,砂糖水の質量、溶けている砂糖の質量
ans = (0, 0, 0)

# まず水の量を考える
for i in range(0, f // (100 * a) + 1):
    for j in range(0, f // (100 * b) + 1):
        if i == 0 and j == 0:
            continue

        # 水の量だけで上限を超えたら終了
        waterV = 100 * a * i + 100 * b * j
        if waterV > f:
            break

        # トータル質量の残り
        leftVolume = f - waterV
        # 砂糖として入れられる最大値
        satouMax = min((a*i + b*j) * e, leftVolume)  # これを作れたら最大

        # 砂糖として入れられる最大値
        sMax = 0
        for si in range(0, satouMax // c + 1):
            blnOk = False
            for sj in range(0, satouMax // d + 1):
                satou = c * si + d * sj
                if satou == satouMax:
                    sMax = satou
                    blnOk = True
                    break
                if satou > satouMax:
                    break
                sMax = max(sMax, satou)

            if blnOk:
                break

        # 濃度計算
        noudo = 100 * sMax / (waterV + sMax)

        if ans[0] < noudo:
            ans = (noudo, waterV+sMax, sMax)

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

Submission status: Wrong Answer

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

print(100,100)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
dp1=[0]*31
dp1[0]=1
m=0
for i in range(1,31):
    if i-A>=0:
        dp1[i]=max(dp1[i],dp1[i-A])
        m=(i)*E
    if i-B>=0:
        dp1[i]=max(dp1[i],dp1[i-B])
        m=(i)*E
dp2=[0]*(1+m)
dp2[0]=1
for i in range(m+1):
    if i-C>=0:
        dp2[i]=max(dp2[i],dp2[i-C])
    if i-D>=0:
        dp2[i]=max(dp2[i],dp2[i-D])
ans=0
w=0
s=0
for i in range(1,31):
    if dp1[i]==0:
        continue
    for j in range(1+m):
        if dp2[j]==0:
            continue
        if j<=i*E and i*100+j<=F:
            if ans<100*j/(i*100+j):
                ans=100*j/(i*100+j)
                w=100*i
                s=j
if s==0:
    print(min(A,B),0)
    quit()
print(w+s,s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
dp1=[0]*31
dp1[0]=1
m=0
for i in range(1,31):
    if i-A>=0:
        dp1[i]=max(dp1[i],dp1[i-A])
        m=(i)*E
    if i-B>=0:
        dp1[i]=max(dp1[i],dp1[i-B])
        m=(i)*E
dp2=[0]*(1+m)
dp2[0]=1
for i in range(m+1):
    if i-C>=0:
        dp2[i]=max(dp2[i],dp2[i-C])
    if i-D>=0:
        dp2[i]=max(dp2[i],dp2[i-D])
ans=0
w=0
s=0
for i in range(1,31):
    if dp1[i]==0:
        continue
    for j in range(1+m):
        if dp2[j]==0:
            continue
        if j<=i*E and i*100+j<=F:
            if ans<100*j/(i*100+j):
                ans=100*j/(i*100+j)
                w=100*i
                s=j
print(w+s,s)

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

Solution code:
#C
A,B,C,D,E,F=map(int,input().split())
density=0
Ans1=0
Ans2=0
water=set() 
sugar=set()

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
#C
A,B,C,D,E,F=map(int,input().split())
density=0
Ans1=0
Ans2=0
water=set() #setを使うと重複がなくなる
sugar=set()
#可能性としてあり得る水の量
bm=F//(100*B)
for i in range(bm+1):
    rw=F-100*i*B
    am=rw//(100*A)
    for j in range(am+1):
        water.add(100*i*B+100*j*A)

#可能性としてあり得る砂糖の量
dm=F//D
for i in range(dm+1):
    rs=F-i*D
    cm=rs//C
    for j in range(cm+1):
        sugar.add(i*D+j*C)
sugar=sorted(sugar)
water=sorted(water)
water.pop(0)
for s in sugar:
    for w in water:
        if w/100*E<s:
            break
        elif s+w>F:
            break
        else:
            den=s/(s+w)
            if den>density:
                density=den
                Ans1=s+w
                Ans2=s
            else:
                break
print(Ans1)
print(Ans2)

Submission status: Wrong Answer

Solution code:
#C
A,B,C,D,E,F=map(int,input().split())
density=0
Ans1=0
Ans2=0
water=set() #setを使うと重複がなくなる
sugar=set()
#可能性としてあり得る水の量
bm=F//(100*B)
for i in range(bm+1):
    rw=F-100*i*B
    am=rw//(100*A)
    for j in range(am+1):
        water.add(100*i*B+100*j*A)

#可能性としてあり得る砂糖の量
dm=F//D
for i in range(dm+1):
    rs=F-i*D
    cm=rs//C
    for j in range(cm+1):
        sugar.add(i*D+j*C)
sugar=sorted(sugar)
water=sorted(water)
water.pop(0)
for s in sugar:
    for w in water:
        if w/100*E<s:
            break
        elif s+w>F:
            break
        else:
            den=s/w
            if den>density:
                density=den
                Ans1=s+w
                Ans2=s
            else:
                break
print(Ans1)
print(Ans2)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
density=0
Ans1=0
Ans2=0
water=set() #setを使うと重複がなくなる
sugar=set()
#可能性としてあり得る水の量
bm=F//(100*B)
for i in range(bm+1):
    rw=F-100*i*B
    am=rw//(100*A)
    for j in range(am+1):
        water.add(100*i*B+100*j*A)

#可能性としてあり得る砂糖の量
dm=F//D
for i in range(dm+1):
    rs=F-i*D
    cm=rs//C
    for j in range(cm+1):
        sugar.add(i*D+j*C)
sugar=sorted(sugar)
sugar.pop(0)
water=sorted(water)
water.pop(0)
for s in sugar:
    for w in water:
        if w/100*E<s:
            break
        elif s+w>F:
            break
        else:
            den=s/w
            if den>density:
                density=den
                Ans1=s+w
                Ans2=s
            else:
                break
print(Ans1)
print(Ans2)

Submission status: Wrong Answer

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

water,sugar = -1,-1
t = 0
for i in range(31):
    for j in range(31):
        for p in range(F//C):
            for q in range(F//D):
                k = i*A + j*B
                pq = p*C + q*D
                if k == 0:
                    break

                if k*100 + pq > F:
                    break

                if k*E >= pq:
                    if t < (100*pq)/(100*k + pq):
                        t = (100*pq)/(100*k + pq)
                        water,sugar = 100*k+pq,pq

print(water,sugar)

Submission status: Wrong Answer

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


def concentration(water, suger):
    if water * E/100 < suger or water + suger == 0:
        return 0
    return (100 * suger/(water + suger))

lst_w = []
limit_w = (F+A*100-1)//(A*100)
for i in range(limit_w):
    for j in range(limit_w):
        if 100 * (A * i + B * j) <= F:
            lst_w += [100 * (A * i + B * j)]

lst_s = []
limit_s = (F+C-1)//C
for i in range(limit_s):
    for j in range(limit_s):
        if C* i + D * j <= F:
            lst_s += [C * i + D * j]

# print (lst_w)
# print (lst_s)
set_w = set(lst_w)
set_s = set(lst_s)

# print (set_w)
# print (set_s)

ans = 0
ans_total = 0
ans_suger = 0
for water in set_w:
    for suger in set_s:
        if water + suger <= F:
            a = concentration(water, suger)
            if ans < a:
                ans = a
                ans_total = water + suger
                ans_suger = suger
            if ans == 50:
                print (ans_total, ans_suger)
                sys.exit()

# print (ans)
print (ans_total, ans_suger)

Submission status: Wrong Answer

Solution code:
from math import ceil

water1, water2, sugar1, sugar2, saturated, max_amount = map(int, input().split(' '))

max_rate = 0
result_amount = 0
result_sugar = 0

for i in range(ceil(max_amount / sugar1 + saturated) + 1):
    for j in range(ceil(max_amount / sugar2 + saturated) + 1):
        sugar = i * sugar1 + j * sugar2
        if sugar > max_amount:
            break
        if sugar + sugar * 100 / saturated > max_amount:
            break
        for k in range(ceil(max_amount / water1) + 1):
            if water1 * 100 * k > max_amount:
                break
            for l in range(ceil(max_amount / water2) + 1):
                water = k * water1 * 100 + l * water2 * 100
                if sugar + water > max_amount:
                    break
                if not water:
                    continue
                rate = sugar / water
                if rate > saturated / 100:
                    continue
                if rate > max_rate:
                    max_rate = rate
                    result_amount = sugar + water
                    result_sugar = sugar
print('{amount} {sugar}'.format(amount=result_amount, sugar=result_sugar))

Submission status: Wrong Answer

Solution code:
import itertools
import math

LIM = 50



def do():
    ans = 0
    A,B,C,D,E,F= list(map(int,input().split(" ")))
    waters = []
    for i in range(31):
        for j in range(31):
            water = A*i* 100+B*j* 100
            if water <= F and water != 0:
                waters.append(water)
    solts = []
    for i in range(3000):
        for j in range(3000):
            solt = C * i + D * j
            if solt > E:
                break
            solts.append(solt)

    max_nodo = -1
    ans_water = 0
    ans_solt = 0
    for solt in solts:
        for water in waters:
            if solt//(water//100) <= E:
                if (100 * solt)/(solt+water) >= max_nodo and water + solt <= F:
                    max_nodo =(100 * solt)/(solt+water)
                    ans_water = water + solt
                    ans_solt = solt

    print(ans_water,ans_solt)





if __name__ == "__main__":
    do()

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
ans=(0,0,0)
F+=1
E=100*E/(100+E)
for a in range(0,F,A*100):
	for b in range(0,F-a,B*100):
		for c in range(0,F-a-b,C):
			if a==0 and b==0:break
			for d in range(0,F-a-b-c,D):
				s=a+b+c+d
				e=100*(c+d)/s
				if ans[2]< e <= E:
					ans=(s,c+d,e)
				elif e>E:break
print(ans[0],ans[1])