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() )

concent = 0
answeight = 0
anssugar = 0
for i in range( F//(100*A) + 1 ):
    for j in range( (F - 100*A*i)//B+1 ):
        water = 100 * (A*i + B*j)
        maxsugar = E * (A*i + B*j)
        if water + maxsugar <= F:
            for k in range( maxsugar//C+1 ):
                sugar = C*k + (maxsugar - C*k)//D
                if 0 < water + sugar and concent < 100 * sugar/(water + sugar):
                    concent = 100 * sugar/(water + sugar)
                    answeight = water + sugar
                    anssugar = sugar

print( answeight, anssugar )

Submission status: Wrong Answer

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


concent = 0
answeight = 0
anssugar = 0
for i in range( F//(100*A)+1 ):
    for j in range( (F - 100*A*i)//B+1 ):
        water = 100 * (i + j)
        maxsugar = water//100 * E
        if water + maxsugar <= F:
            for k in range( maxsugar//C+1 ):
                for l in range( (maxsugar - C*k)//D+1 ):
                    sugar = C*k + D*l
                    if 0 < water + sugar and water + sugar <= F:
                        if concent < sugar/(water + sugar):
                            concent = sugar/(water + sugar)
                            answeight = water + sugar
                            anssugar = sugar

print( answeight, anssugar )

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
water = []
for i in range(31):
    for j in range(31):
        if a * i * 100 + b * j * 100 > f:
            break
        water.append(a * i * 100 + b * j * 100)
        
water = sorted(list(set(water)))
sugar = []
for i in range(3001):
    for j in range(3001):
        if c * i + d * j > f:
            break
        sugar.append(c * i + d * j)
        
sugar = sorted(list(set((sugar))))

sugar_ratio = 0
for i in water:
    for j in sugar:
        if i != 0:
            sugar_water = i + j
            if sugar_water <= f:
                if float(j) / i * 100 <= e:
                    if float(j) / sugar_water >= sugar_ratio:
                        sugar_ratio = float(j) / sugar_water
                        ans_sugar_water = sugar_water
                        ans_sugar = j
                        
print(ans_sugar_water, ans_sugar)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
water = []
for i in range(31):
    for j in range(31):
        if a * i * 100 + b * j * 100 > f:
            break
        water.append(a * i * 100 + b * j * 100)
        
water = sorted(list(set(water)))
sugar = []
for i in range(3001):
    for j in range(3001):
        if c * i + d * j > f:
            break
        sugar.append(c * i + d * j)
        
sugar = sorted(list(set((sugar))))

sugar_ratio = 0
for i in water:
    for j in sugar:
        if i != 0:
            if (i + j) <= f:
                if j / i * 100 <= e:
                    if j / (i + j) >= sugar_ratio:
                        sugar_ratio = j / (i + j)
                        ans_sugar_water = i + j
                        ans_sugar = j
                        
print(ans_sugar_water, ans_sugar)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
water = []
for i in range(31):
    for j in range(31):
        if a * i * 100 + b * j * 100 >= 3000:
            break
        water.append(a * i * 100 + b * j * 100)
        
water = sorted(list(set(water)))
sugar = []
for i in range(3001):
    for j in range(3001):
        if c * i + d * j >= 3000:
            break
        sugar.append(c * i + d * j)
        
sugar = sorted(list(set((sugar))))

sugar_ratio = 0
ans_sugar_water = 0 
ans_sugar = 0
for i in water:
    for j in sugar:
        if i != 0 and j != 0:
            if (i + j) <= f:
                if j / i * 100 <= e:
                    if j / (i + j) > sugar_ratio:
                        sugar_ratio = j / (i + j)
                        ans_sugar_water = i + j
                        ans_sugar = j
                        
print(ans_sugar_water, ans_sugar)

Submission status: Wrong Answer

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

total=0
s=0
max=0
for w in range(31):
    for x in range(16):
        for y in range(101):
            for z in range(51):
                water=100*(w*a+x*b)
                sugar=y*c+z*d
                if water==0:
                    m=INF
                else:
                    m=(sugar/water)*100
                if water+sugar<=f and m<=e:
                    n=100*sugar/(water+sugar)
                    if n>max:
                        max=n
                        total=sugar+water
                        s=sugar
print(total,s)

Submission status: Wrong Answer

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

total=0
s=0
max=0
for w in range(31):
    for x in range(31):
        for y in range(31):
            for z in range(31):
                water=100*(w*a+x*b)
                sugar=y*c+z*d
                if water==0:
                    m=INF
                else:
                    m=(sugar/water)*100
                if water+sugar<=f and m<=e:
                    if m>max:
                        max=m
                        total=sugar+water
                        s=sugar
print(total,s)

Submission status: Wrong Answer

Solution code:
#ABC074C
A,B,C,D,E,F=map(int,input().split())
ans=0
sw=100*A #SugarWater
s=0 #Sugar
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		if a+b!=0:
			for c in range(0,F-a-b+1,C):
				for d in range(0,F-a-b-c,D):
					if 0<a+b+c+d<=F and (c+d)/(a+b)<E/100:
						if ans < (c+d)/(a+b+c+d):
							ans=(c+d)/(a+b+c+d)
							sw=a+b+c+d
							s=c+d
print(sw,s)

Submission status: Wrong Answer

Solution code:
#ABC074C
A,B,C,D,E,F=map(int,input().split())
ans=-1
sw=100*A #SugarWater
s=0 #Sugar
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		if a+b!=0:
			for c in range(0,F-a-b+1,C):
				d=(E*(a+b)//100 -c)//D
				d*=D
				if d<0:
					break
				if 0<a+b+c+d<=F and 0<a+b:
					if ans < (c+d)/(a+b+c+d):
						ans=(c+d)/(a+b+c+d)
						sw=a+b+c+d
						s=c+d
print(sw,s)

Submission status: Wrong Answer

Solution code:
#ABC074C
A,B,C,D,E,F=map(int,input().split())
ans=-1
sw=100*A #SugarWater
s=0 #Sugar
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		if a+b!=0:
			for c in range(0,F-a-b+1,C):
				d=(E*(a+b)//100 -c)//D
				d*=D
				if d<0:
					break
				if 0<a+b+c+d<=F:
					if ans < (c+d)/(a+b+c+d):
						ans=(c+d)/(a+b+c+d)
						sw=a+b+c+d
						s=c+d
print(sw,s)

Submission status: Wrong Answer

Solution code:
#ABC074C
A,B,C,D,E,F=map(int,input().split())
ans=0
sw=100*A #SugarWater
s=0 #Sugar
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		if a+b!=0:
			for c in range(0,F-a-b+1,C):
				d=(E*(a+b)//100 -c)//D
				d*=D
				if d<0:
					break
				if 0<a+b+c+d<=F:
					if ans < (c+d)/(a+b+c+d):
						ans=(c+d)/(a+b+c+d)
						sw=a+b+c+d
						s=c+d
print(sw,s)

Submission status: Wrong Answer

Solution code:
#ABC074C
A,B,C,D,E,F=map(int,input().split())
a,b,c,d=0,0,0,0
ans=0
sw=0 #SugarWater
s=0 #Sugar
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		if a+b!=0:
			for c in range(0,F-a-b+1,C):
				d=(E*(a+b)//100 -c)//D
				d*=D
				if d<0:
					break
				if 0<a+b+c+d<=F:
					if ans < (c+d)/(a+b+c+d):
						ans=(c+d)/(a+b+c+d)
						sw=a+b+c+d
						s=c+d
print(sw,s)

Submission status: Wrong Answer

Solution code:
#ABC074C
A,B,C,D,E,F=map(int,input().split())
a,b,c,d=0,0,0,0
ans=0
sw=0 #SugarWater
s=0 #Sugar
for a in range(0,F,100*A):
	for b in range(0,F-a,100*B):
		if a+b!=0:
			for c in range(0,F-a-b,C):
				d=(E*(a+b)//100 -c)//D
				d*=D
				if d<0:
					break
				if 0<a+b+c+d<=F:
					if ans < (c+d)/(a+b+c+d):
						ans=(c+d)/(a+b+c+d)
						sw=a+b+c+d
						s=c+d
print(sw,s)

Submission status: Wrong Answer

Solution code:
#ABC074C
A,B,C,D,E,F=map(int,input().split())
a,b,c,d=0,0,0,0
ans=0
sw=0 #SugarWater
s=0 #Sugar
for a in range(0,F,100*A):
	for b in range(0,F-a,100*B):
		if a+b!=0:
			for c in range(0,min(F-a-b,E*(a+b)//100)+1,C):
				d=(E*(a+b)//100 -c)//D
				d*=D
				if 0<a+b+c+d<=F:
					if ans < (c+d)/(a+b+c+d):
						ans=(c+d)/(a+b+c+d)
						sw=a+b+c+d
						s=c+d
print(sw,s)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
g = max(a, b)
h = min(a, b)
salt = []
water = []
concentration = 0

for i in range(int(e*f/(c*100)) + 1):
    j = 0
    while e*f/100 >= c*i +d*j:
        salt.append(c*i+d*j)
        j += 1
salt.sort()

for i in range(int(f/(100*g)) + 1):
    j = 0
    while f >= 100*(g*i+h*j):
        water.append(100*(g*i+h*j))
        j += 1
water.sort()
water = water[1:]

for i in range(len(water)):
    addsalt = min(water[i] * e // 100, f - water[i])
    while addsalt not in salt:
        addsalt -=1
    if concentration < addsalt / (water[i] + addsalt):
        concentration = addsalt / (water[i] + addsalt)
        salt1 = addsalt
        water1 = water[i]

try:
    print(salt1+water1, salt1)
except NameError:
    print(0, water[0])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
mx_A=F//(100*A)
mx_B=F//(100*B)
mx_C=F//C
mx_D=F//D
Conc=0
Vol=0
Sal=0
for i in range(mx_A+1):
    for j in range(mx_B+1):
        if 0<100*(A*i+B*j)<=F:
            for k in range(mx_C+1):
                for l in range(mx_D+1):
                    m_Sal=C*k+D*l
                    m_Wat=100*(A*i+B*j)
                    if (m_Sal+m_Wat)<=F and m_Sal<=(E*m_Wat/100):
                        if (m_Sal/(m_Sal+m_Wat))>Conc:
                            Conc=(m_Sal/(m_Sal+m_Wat))
                            Sal=m_Sal
                            Vol=m_Sal+m_Wat
print(Vol,Sal)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
mx_A=F//(100*A)
mx_B=F//(100*B)
mx_C=F//C
mx_D=F//D
Conc=0
Vol=0
Sal=0
for i in range(mx_A+1):
    for j in range(mx_B+1):
        if 0<100*(A*i+B*j)<F:
            for k in range(mx_C+1):
                for l in range(mx_D+1):
                    m_Sal=C*k+D*l
                    m_Wat=100*(A*i+B*j)
                    if (m_Sal+m_Wat)<=F and m_Sal<=(E*m_Wat/100):
                        if (m_Sal/(m_Sal+m_Wat))>Conc:
                            Conc=(m_Sal/(m_Sal+m_Wat))
                            Sal=m_Sal
                            Vol=m_Sal+m_Wat
print(Vol,Sal)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 01:07:09 2019

@author: yuta
"""

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

def melt(a,b,c,d,e,f):
    max_sugar = 0
    for i in range(int(0.01*f/a)+1):
        for j in range(int(0.01*f/b)+1):
            for k in range(31):
                for l in range(31):
                    if i+j+k+l == 0:
                        break
                    else:
                        den = (100*(k*c+l*d))/(100*i*a+100*j*b+k*c+l*d)
                        if den > 100*e/(100+e):
                            den = 0
                        else:
                            if den >= max_sugar and 100*i*a+100*j*b+k*c+l*d <= f:
                                max_sugar = den
                                amount = 100*i*a + 100*j*b + k*c + l*d
                                sugar = 0.01 * den * amount
    print(amount,sugar)

melt(A,B,C,D,E,F)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 01:07:09 2019

@author: yuta
"""

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

def melt(a,b,c,d,e,f):
    max_sugar = 0
    for i in range(int(0.01*f/a)+1):
        for j in range(int(0.01*f/b)+1):
            for k in range(int(e/c)+1):
                for l in range(int(e/d)+1):
                    if i+j+k+l == 0:
                        break
                    else:
                        den = (100*(k*c+l*d))/(100*i*a+100*j*b+k*c+l*d)
                        if den > 100*e/(100+e):
                            den = 0
                        else:
                            if den >= max_sugar and i+j+k+l <= f:
                                max_sugar = den
                                amount = 100*i*a + 100*j*b + k*c + l*d
                                sugar = 0.01 * den * amount
    print(amount,sugar)

melt(A,B,C,D,E,F)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = (int(i) for i in input().split())
sa = sab = sabc = sabcd = sc = scd = water = sugar = dens = 0
for i in range(31):
  sa = a*i*100
  if sa > f:
    break
  for j in range(16):
    sab = b*j*100 + sa
    if sab > f or sab == 0:
      break
    for k in range(1501):
      sc = c*k
      sabc = sc + sab
      if sabc > f or sc > e * sab / 100:
        break
      for l in range(1501):
        scd = sc + d*l
        sabcd = d*l + sabc
        if sabcd > f or scd > e * sab / 100:
          break
        if dens < scd / sabcd:
          dens = scd / sabcd
          water = sabcd
          sugar = scd
print(str(water) + ' ' + str(sugar))

Submission status: Wrong Answer

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

ans = sorted(ans)
print(ans[-1][1]+ans[-1][2],ans[-1][2])

Submission status: Wrong Answer

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

ans = sorted(ans)
print(ans[-1][1]+ans[-1][2],ans[-1][2])

Submission status: Wrong Answer

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

ans = sorted(ans)
print(ans[-1][1]+ans[-1][2],ans[-1][2])

Submission status: Wrong Answer

Solution code:
import itertools

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

xset, yset = set(), set()
for i in range((f + 100*a) // (100*a)):
  for j in range((f-(100*a*i) + 100*b) // (100*b)):
    xset.add(100*a*i + 100*b*j)

for i in range((f+c) // c):
  for j in range((f-c*i+d) // d):
    yset.add(c*i + d*j)

maxd = (0, 0, 0)
for x, y in itertools.product(xset, yset):
  if (x==0 and y==0) or x + y > f or x // 100 * e < y:
    continue
  else:
    if maxd[0] < y / (x + y) * 100:
      maxd = (y / (x + y) * 100, x, y)
print(maxd[1]+maxd[2], maxd[2])

Submission status: Wrong Answer

Solution code:
import itertools

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

xset, yset = set(), set()
for i in range((f + 100*a) // (100*a)):
  for j in range((f-(100*a*i) + 100*b) // (100*b)):
    xset.add(100*a*i + 100*b*j)

for i in range(f // c):
  for j in range((f-c*i) // d):
    yset.add(c*i + d*j)

maxd = (0, 0, 0)
for x, y in itertools.product(xset, yset):
  if (x==0 and y==0) or x + y > f or x // 100 * e < y:
    continue
  else:
    if maxd[0] < y / (x + y) * 100:
      maxd = (y / (x + y) * 100, x, y)
print(maxd[1]+maxd[2], maxd[2])

Submission status: Wrong Answer

Solution code:
def c_sugar_water(A, B, C, D, E, F):
    x = set()  # 水の量が取りうるパターン
    y = set()  # 砂糖の量が取りうるパターン
    for a in range(0, F + 1, 100 * A):
        for b in range(0, F - a + 1, 100 * B):
            x.add(a + b)
    for c in range(0, F + 1, C):
        for d in range(0, F - c + 1, D):
            y.add(c + d)

    concentration = -0.0  # 砂糖水の濃度
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            # 砂糖水の質量がビーカーに入れられるもので、砂糖が溶け残らない
            if 0 < water + sugar <= F and E * (water // 100) >= sugar:
                if concentration < sugar / (water + sugar):
                    tmp = (water + sugar, sugar)
                    concentration = sugar / (water + sugar)
    ans = '{} {}'.format(*tmp)
    return ans

A, B, C, D, E, F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Submission status: Wrong Answer

Solution code:
def c_sugar_water(A, B, C, D, E, F):
    x = set()  # 水の量が取りうるパターン
    y = set()  # 砂糖の量が取りうるパターン
    for a in range(0, F + 1, 100 * A):
        for b in range(0, F - a + 1, 100 * B):
            x.add(a + b)
    for c in range(0, F + 1, C):
        for d in range(0, F - c + 1, D):
            y.add(c + d)

    concentration = -0.0  # 砂糖水の濃度
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            # 砂糖水の質量がビーカーに入れられるもので、砂糖が溶け残らない
            if 0 < water + sugar <= F and E * water // 100 >= sugar:
                if concentration < sugar / (water + sugar):
                    tmp = (water + sugar, sugar)
                    concentration = sugar / (water + sugar)
    ans = '{} {}'.format(*tmp)
    return ans

A, B, C, D, E, F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Submission status: Wrong Answer

Solution code:
def c_sugar_water(A, B, C, D, E, F):
    x = set()  # 水の量が取りうるパターン
    y = set()  # 砂糖の量が取りうるパターン
    for a in range(0, F + 1, 100 * A):
        for b in range(0, F - a + 1, 100 * B):
            x.add(a + b)
    for c in range(0, F + 1, C):
        for d in range(0, F - c + 1, D):
            y.add(c + d)

    concentration = 0  # 砂糖水の濃度
    tmp = [0, 0]
    for water in x:
        for sugar in y:
            # 砂糖水の質量がビーカーに入れられるもので、砂糖が溶け残らない
            if 0 < water + sugar <= F and E * water // 100 >= sugar:
                if concentration < sugar / (water + sugar):
                    tmp = (water + sugar, sugar)
                    concentration = sugar / (water + sugar)
    ans = '{} {}'.format(*tmp)
    return ans

A, B, C, D, E, F = [int(i) for i in input().split()]
print(c_sugar_water(A, B, C, D, E, F))

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
water_list = []
for i in range(f+1):
    for j in range(f+1):
        water = a * 100 * i + b * 100 * j
        if water <= f:
            water_list.append(water)
        else:
            break
            
sugar_list = []
for i in range(f+1):
    for j in range(f+1):
        sugar = c * i + d * j
        if sugar <= f:
            sugar_list.append(sugar)
        else:
            break
            
ans = []
for i in list(set(water_list)):
    for j in list(set(sugar_list)):
        if i != 0:
            if j / i * 100 <= e and (i + j) <= f:
                ans.append((i+j, j))
                
ans_sorted = sorted(ans, key=lambda x: (x[1] / (x[0])))[-1]
print(ans_sorted[0],ans_sorted[1])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
water_list = []
for i in range(f+1):
    for j in range(f+1):
        water = a * 100 * i + b * 100 * j
        if water <= f:
            water_list.append(water)
        else:
            break
            
sugar_list = []
for i in range(f+1):
    for j in range(f+1):
        sugar = c * i + d * j
        if sugar <= f:
            sugar_list.append(sugar)
        else:
            break
            
ans = []
for i in list(set(water_list)):
    for j in list(set(sugar_list)):
        if i != 0:
            if j / i * 100 <= e and (i + j) <= f:
                ans.append((i+j, j))
                
ans_sorted = sorted(ans, key=lambda x: (x[1] / (x[0])))[-1]
print(ans_sorted)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)
 
sugar_a = [0]
sugar_b = [0]
for i in range(100):
    for j in range(100):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check <= f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check <= f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))
 
from bisect import bisect_left,bisect_right
sugar_max_a = sugar_sort_a[bisect_left(sugar_sort_a, max_a)-1]
a_check = sugar_max_a / (a* 100 + sugar_max_a)
 
sugar_max_b = sugar_sort_b[bisect_left(sugar_sort_b, max_b)-1] 
b_check = sugar_max_b / (b*100 + sugar_max_b)
 
if a_check >= b_check:
    print(a*100+sugar_max_a, sugar_max_a)
else:
    print(b*100+sugar_max_b, sugar_max_b)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)
 
sugar_a = [0]
sugar_b = [0]
for i in range(100):
    for j in range(100):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check <= f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check <= f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))
 
from bisect import bisect_left,bisect_right
sugar_max_a = sugar_sort_a[bisect_right(sugar_sort_a, max_a)-1]
a_check = sugar_max_a / (a* 100 + sugar_max_a)
 
sugar_max_b = sugar_sort_b[bisect_right(sugar_sort_b, max_b)-1] 
b_check = sugar_max_b / (b*100 + sugar_max_b)
 
if a_check > b_check:
    print(a*100+sugar_max_a, sugar_max_a)
else:
    print(b*100+sugar_max_b, sugar_max_b)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)
 
sugar_a = [0]
sugar_b = [0]
for i in range(100):
    for j in range(100):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check < f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check < f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))
 
from bisect import bisect_left,bisect_right
sugar_max_a = sugar_sort_a[bisect_right(sugar_sort_a, max_a)-1]
a_check = sugar_max_a / (a* 100 + sugar_max_a)
 
sugar_max_b = sugar_sort_b[bisect_right(sugar_sort_b, max_b)-1] 
b_check = sugar_max_b / (b*100 + sugar_max_b)
 
if a_check >= b_check:
    print(a*100+sugar_max_a, sugar_max_a)
else:
    print(b*100+sugar_max_b, sugar_max_b)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
max_a = a * 100 * e * 10 ** (-2)
max_b = b * 100 * e * 10 ** (-2)

sugar_a = [0]
sugar_b = [0]
for i in range(100):
    for j in range(100):
        sugar_check = c * i + d * j
        if a * 100 + sugar_check <= f:
            sugar_a.append(sugar_check)
        if b * 100 + sugar_check <= f:
            sugar_b.append(sugar_check)
            
sugar_sort_a = sorted(list(set(sugar_a)))
sugar_sort_b = sorted(list(set(sugar_b)))

from bisect import bisect_left,bisect_right
sugar_max_a = sugar_sort_a[bisect_right(sugar_sort_a, max_a)-1]
a_check = sugar_max_a / (a* 100 + sugar_max_a)

sugar_max_b = sugar_sort_b[bisect_right(sugar_sort_b, max_b)-1] 
b_check = sugar_max_b / (b*100 + sugar_max_b)

if a_check >= b_check:
    print(a*100+sugar_max_a, sugar_max_a)
else:
    print(b*100+sugar_max_b, sugar_max_b)

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

li = list(map(int,input().split()))
A, B, C, D, E, F = li[0], li[1], li[2], li[3], li[4], li[5]

A, B = A*100, B*100

N = E//A+1

waters = set()
sugers = set()

for i in range(N+1):
    j = 0
    while True:
        water = A*i + B*j
        if  water <= F:
            waters.add(water)
        else:
            break
        j += 1

M = E//C+1

for i in range(M+1):
    j = 0
    while True:
        suger = C*i + D*j
        if suger <= F:
            sugers.add(suger)
        else:
            break
        j += 1

# print(waters)
# print(sugers)
ans = 0
ans_water = 0
ans_suger = 0
for water in waters:
    for suger in sugers:
        if water == 0 or suger == 0 or E/100 <= suger/water or suger+water > F:
            continue
        tmp_p = (100*suger)/(water+suger)
        if tmp_p >= ans:
            ans = tmp_p
            ans_water = water
            ans_suger = suger

print("{} {}".format(ans_water+ans_suger, ans_suger))

Submission status: Wrong Answer

Solution code:
import itertools
Wa,Wb,Ga,Gb,Cmax,Gmax = list(map(int,input().split()))

W = [Wb*100*i for i in range(1,31) if Wb*100*i<Gmax]
G = []

i = 0
while Wa*i*100<=Gmax:
  i += 1
  j = 0
  while Wa*i*100+Wb*j*100<=Gmax:
    W.append(Wa*i*100+Wb*j*100)
    j += 1

i = -1
while Ga*i<=Gmax:
  i += 1
  j = 0
  while Ga*i+Gb*j<=Gmax:
    G.append(Ga*i+Gb*j)
    j += 1

W = sorted(list(set(W)),reverse=True) 
G = sorted(list(set(G)),reverse=True) 
W.sort()

ans = 0
tmp = 0
for i in W:
  for j in G:
    if i+j<=Gmax and j*100/i<=Cmax:
      if tmp < j*100/i:
        tmp = j*100/i
        ans = str(i+j)+" "+str(j)

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
Wa,Wb,Ga,Gb,Cmax,Gmax = list(map(int,input().split()))

W = [Wb*100]
G = []

i = 0
while Wa*i*100<=Gmax:
  i += 1
  j = 0
  while Wa*i*100+Wb*j*100<=Gmax:
    W.append(Wa*i*100+Wb*j*100)
    j += 1

i = -1
while Ga*i<=Gmax:
  i += 1
  j = 0
  while Ga*i+Gb*j<=Gmax:
    G.append(Ga*i+Gb*j)
    j += 1

W = sorted(list(set(W)),reverse=True) 
G = sorted(list(set(G)),reverse=True) 
W.sort()

ans = 0
tmp = 0
for i in W:
  for j in G:
    if i+j<=Gmax and j*100/i<=Cmax:
      if tmp < j*100/i:
        tmp = j*100/i
        ans = str(i+j)+" "+str(j)

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
Wa,Wb,Ga,Gb,Cmax,Gmax = list(map(int,input().split()))

W = []
G = []

i = 0
while Wa*i*100<=Gmax:
  i += 1
  j = 0
  while Wa*i*100+Wb*j*100<=Gmax:
    W.append(Wa*i*100+Wb*j*100)
    j += 1

i = -1
while Ga*i<=Gmax:
  i += 1
  j = 0
  while Ga*i+Gb*j<=Gmax:
    G.append(Ga*i+Gb*j)
    j += 1

W = sorted(list(set(W)),reverse=True) 
G = sorted(list(set(G)),reverse=True) 
W.sort()

ans = 0
tmp = 0
for i in W:
  for j in G:
    if i+j<=Gmax and j*100/i<=Cmax:
      if tmp < j*100/i:
        tmp = j*100/i
        ans = str(i+j)+" "+str(j)

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
Wa,Wb,Ga,Gb,Cmax,Gmax = list(map(int,input().split()))

W = []
G = []

i = 0
while Wa*i*100<=Gmax:
  i += 1
  j = 0
  while Wa*i*100+Wb*j*100<=Gmax:
    W.append(Wa*i*100+Wb*j*100)
    j += 1

i = 0
while Ga*i<=Gmax:
  i += 1
  j = 0
  while Ga*i+Gb*j<=Gmax:
    G.append(Ga*i+Gb*j)
    j += 1
    
G = sorted(list(set(G)),reverse=True) 
W.sort()

ans = 0
tmp = 0
for i in W:
  for j in G:
    if i+j<=Gmax and j*100/i<=Cmax:
      if tmp < j*100/i:
        tmp = j*100/i
        ans = str(i+j)+" "+str(j)

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A,B,C,D,E,F = map(int,input().split())
# d = b/(a+b)を最大化したい
# 条件1: 100*b <= a*E
# 条件2: a + b <= F
# 条件3: a % (100*gcd(A,B)) == 0
# 条件4: b % gcd(C,D) == 0
# (100A)i + (100B)j = a となる非負整数i,jが存在する => 条件3
# (C)k + (D)l = b となる非負整数k,lが存在する => 条件4
# d <= d'  <=>  b/(a+b) <= b'/(a'+b')  <=>  (a'+b')b <= (a+b)b'
a_d = 100*gcd(A,B); b_d = gcd(C,D)
ans_a = 0; ans_b = 0
candidate = []
# 必要条件で絞り込み
for a in range(a_d,F+1,a_d):
    b_sup = F - a
    for b in range(b_d,b_sup+1,b_d):
        if not(100*b <= a*E and a % a_d == 0 and b % b_d == 0):
            continue
        candidate.append([a,b])
# 十分性の確認
for a, b in candidate:
    cnt = 0
    nA = (100*A) // a_d; nB = (100*B) // a_d; na = a // a_d
    # nAi + nBj = a を満たす非負整数i,jの存在を判定
    # nAi <= na  <=>  i <= na / nA
    for i in range(-(-na // nA)+1):
        # j = (a-Ai) / B, jは整数
        if (na-nA*i) % nB == 0:
            cnt += 1
            break
    nC = C // b_d; nD = D // b_d; nb = b // b_d
    # nCk + nDl = nb を満たす非負整数k,lの存在を判定
    # nCk <= nb  <=>  k <= nb / nC
    for k in range(-(-nb//nC)+1):
        # l = (nb-nCk) / nD, lは整数
        if (nb-nC*k) % nD == 0:
            cnt += 1
            break
    if cnt == 2 and (a+b)*ans_b <= (ans_a+ans_b)*b:
        ans_a = a; ans_b = b
print(ans_a+ans_b,ans_b)