Problem:


Score : 300 points

Problem Statement

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

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

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

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

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

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

Snuke will make sugar water with the highest possible density.

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

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

Constraints

1 \leq A < B \leq 30

1 \leq C < D \leq 30

1 \leq E \leq 100

100A \leq F \leq 3 000

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

Inputs

Input is given from Standard Input in the following format:

A B C D E F

Outputs

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

Sample Input 1

1 2 10 20 15 200

Sample Output 1

110 10

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

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

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

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

Sample Input 2

1 2 1 2 100 1000

Sample Output 2

200 100

There are other acceptable outputs, such as:

400 200

However, the output below is not acceptable:

300 150

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

Sample Input 3

17 19 22 26 55 2802

Sample Output 3

2634 934



Sample input:
1 2 10 20 15 200


Sample output:
110 10

Submission status: Wrong Answer

Solution code:
import sys

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

dp = [0]*(f+1)

for i in range(f+1):
    if i == 0 or dp[i]:
        if i+100*a <= f:
            dp[i+100*a] = 1

for i in range(f+1):
    if i == 0 or dp[i]:
        if i+100*b <= f:
            dp[i+100*b] = 1

for i in range(f+1):
    if i == 0 or dp[i]:
        if i+c <= f and (c+dp[i+c])*100 <= e*(i-dp[i+c]):
            print(i+c, c)
            sys.exit()

for i in range(f+1):
    if i == 0 or dp[i]:
        if i+d <= f and (d+dp[i+d])*100 <= e*(i-dp[i+d]):
            print(i+d, d)
            sys.exit()

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split(' '))
ans_suger_water = A
ans_suger = C
max_conc = 0
conc_filter = E / (100 + E)
suger_water = A
suger = C
for a in range(0, int(F/100/A)+1):
    for b in range(0, int((F-100*a*A)/100/B)+1):
        water = 100*A*a + 100*B*b
        if (water == 0): continue
        for c in range(0, int((F-water)/C)+1):
            for d in range(0, int((F-water-C*c)/D)+1):
                # print(c, d)
                suger = C*c + D*d
                suger_water = water + suger
                if (suger_water > F): break
                conc = suger / suger_water
                if (conc > conc_filter): break
                if conc > max_conc:
                    max_conc = conc
                    ans_suger = suger
                    ans_suger_water = suger_water
print(ans_suger_water, ans_suger)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split(' '))
ans_suger_water = 0
ans_suger = 0
max_conc = 0
conc_filter = E / (100 + E)
suger_water = A
suger = C
for a in range(0, int(F/100/A)+1):
    for b in range(0, int((F-100*a*A)/100/B)+1):
        water = 100*A*a + 100*B*b
        if (water == 0): continue
        for c in range(0, int((F-water)/C)+1):
            for d in range(0, int((F-water-C*c)/D)+1):
                suger = C*c + D*d
                suger_water = water + suger
                if (suger_water > F): break
                conc = suger / suger_water
                if (conc > conc_filter): break
                if conc > max_conc:
                    max_conc = conc
                    ans_suger = suger
                    ans_suger_water = suger_water
print(ans_suger_water, ans_suger)

Submission status: Wrong Answer

Solution code:
A, B, C, D, E, F = map(int, input().split(' '))
ans_suger_water = 0
ans_suger = 0
max_conc = 0
conc_filter = E / 100
suger_water = A
suger = C
for a in range(0, 31):
    for b in range(0, 31):
        for c in range(0, 31):
            for d in range(0, 31):
                suger = C*c + D*d
                suger_water = 100*A*a + 100*B*b + suger
                if (suger_water > F): continue
                if (suger_water == 0): continue
                conc = suger / suger_water
                if (conc > conc_filter): continue
                if conc > max_conc:
                    ans_suger = suger
                    ans_suger_water = suger_water
print(ans_suger_water, ans_suger)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
m_d = 0
m_t = 0
m_s = 0
for a in range(F//100*A+1):
  for b in range((F-100*A*a)//(100*B)+1):
    for c in range((F-A*a*100-B*b*100)//C+1):
      d = 0
      while (100*A*a+100*B*b) > 0 and 100*A*a+100*B*b+C*c+D*d <= F and (C*c+D*d)/(100*A*a+100*B*b) <= E/100:
        dens = (C*c+D*d)/(100*A*a+100*B*b)
        if (C*c+D*d)/(100*A*a+100*B*b) == E/100:
          print(100*A*a+100*B*b+C*c+D*d,C*c+D*d)
          exit()
        elif m_d < dens:
          m_d = dens
          m_t = 100*A*a+100*B*b+C*c+D*d
          m_s = C*c+D*d
        d += 1
print(m_t,m_s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
m_d = 0
m_t = 0
m_s = 0
for a in range(F//100*A+1):
  for b in range((F-100*A*a)//(B)+1):
    for c in range((F-A*a*100-B*b*100)//C+1):
      d = 0
      while (100*A*a+100*B*b) > 0 and 100*A*a+100*B*b+C*c+D*d <= F and (C*c+D*d)/(100*A*a+100*B*b) <= E/100:
        dens = (C*c+D*d)/(100*A*a+100*B*b)
        if (C*c+D*d)/(100*A*a+100*B*b) == E/100:
          print(100*A*a+100*B*b+C*c+D*d,C*c+D*d)
          exit()
        elif m_d < dens:
          m_d = dens
          m_t = 100*A*a+100*B*b+C*c+D*d
          m_s = C*c+D*d
        d += 1
print(m_t,m_s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
m_d = 0
m_t = 0
m_s = 0
for a in range(F//100*A+1):
  for b in range((F-100*A*a)//(B)+1):
    for c in range((F-A*a*100-B*b*100)//C+1):
      d = 0
      while (100*A*a+100*B*b) > 0 and 100*A*a+100*B*b+C*c+D*d < F and (C*c+D*d)/(100*A*a+100*B*b) <= E/100:
        dens = (C*c+D*d)/(100*A*a+100*B*b)
        if (C*c+D*d)/(100*A*a+100*B*b) == E/100:
          print(100*A*a+100*B*b+C*c+D*d,C*c+D*d)
          exit()
        elif m_d < dens:
          m_d = dens
          m_t = 100*A*a+100*B*b+C*c+D*d
          m_s = C*c+D*d
        d += 1
print(m_t,m_s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
m_d = 0
m_t = 0
m_s = 0
for a in range(F//100*A+1):
  for b in range((F-100*A*a)//(B)+1):
    for c in range((F-A*a*100-B*b*100)//C+1):
      d = 0
      while (100*A*a+100*B*b) > 0 and 100*A*a+100*B*b+C*c+D*d < F and (C*c+D*d)/(100*A*a+100*B*b) <= E/100:
        dens = (C*c+D*d)/(100*A*a+100*B*b)
        if (C*c+D*d)/(100*A*a+100*B*b) == E/100:
          print(100*A*a+100*B*b+C*c+D*d,C*c+D*d)
          exit()
        elif m_d < dens:
          m_d = dens
          m_t = 100*A*a+100*B*b+C*c+D*d
          m_s = C*c+D*d
        d += 1
print(m_t,m_s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
A = 100*A
B = 100*B
m_d = 0
m_t = 0
m_s = 0
for a in range(F//A+1):
  for b in range((F-A*a)//(B)+1):
    for c in range((F-A*a-B*b)//C+1):
      d = 0
      while (A*a+B*b) > 0 and A*a+B*b+C*c+D*d < F and (C*c+D*d)/(A*a+B*b) <= E/100:
        dens = (C*c+D*d)/(A*a+B*b)
        if (C*c+D*d)/(A*a+B*b) == E/100:
          print(A*a+B*b+C*c+D*d,C*c+D*d)
          exit()
        elif m_d < dens:
          m_d = dens
          m_t = A*a+B*b+C*c+D*d
          m_s = C*c+D*d
        d += 1
print(m_t,m_s)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F = map(int,input().split())
A = 100*A
B = 100*B
m_d = 0
m_t = 0
m_s = 0
for a in range(F//A+1):
  for b in range((F-A*a)//(B)+1):
    for c in range((F-A*a-B*b)//C+1):
      d = 0
      while (A*a+B*b) > 0 and A*a+B*b+C*c+D*d < F and (C*c+D*d)/(A*a+B*b) < E/100:
        dens = (C*c+D*d)/(A*a+B*b)
        if m_d < dens:
          m_d = dens
          m_t = A*a+B*b+C*c+D*d
          m_s = C*c+D*d
        d += 1
print(m_t,m_s)

Submission status: Wrong Answer

Solution code:
import math

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

water = []
max_water_num = int(F / min(A*100,B*100))
#print("max_water_num",max_water_num)
for a_num in range(0,max_water_num+1):
  for b_num in range(0,max_water_num+1):
    w = a_num*A*100 + b_num*B*100
    if w + w/100*E <= F:
      water.append(w)

      
water = set(water)
water = sorted(water)
#print("water candidates", water)

sugar_ans = 0
water_ans  = water[0]
max_rate = 0

max_sugar_num = int(max(water)/100*E/min(C,D))+1
#print("max_sugar_num", max_sugar_num)
for w in water:
  if not w == 0:
    max_sugar = round(w /100 * E)
    #print(max_sugar)
    #print(min_dif)
    for c_num in range(max_sugar_num+1):
      for d_num in range(max_sugar_num+1):
        sugar = C*c_num + D*d_num
        if max_sugar >= sugar:
          rate = 100*sugar/(sugar+ w)
          if rate > max_rate:
            max_rate = rate
            sugar_ans = sugar
            water_ans = sugar + w

print(water_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
import math

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

water = []
max_water_num = int(F / min(A*100,B*100))
#print("max_water_num",max_water_num)
for a_num in range(0,max_water_num+1):
  for b_num in range(0,max_water_num+1):
    w = a_num*A*100 + b_num*B*100
    if w + w/100*E <= F:
      water.append(w)

      
water = set(water)
water = sorted(water)
#print("water candidates", water)

sugar_ans = 0
water_ans  = water[0]
max_rate = 0

max_sugar_num = int(max(water)/100*E/min(C,D))+1
#print("max_sugar_num", max_sugar_num)
for w in water:
  if not w == 0:
    max_sugar = int(w /100 * E)
    #print(max_sugar)
    #print(min_dif)
    for c_num in range(max_sugar_num+1):
      for d_num in range(max_sugar_num+1):
        sugar = C*c_num + D*d_num
        if max_sugar >= sugar:
          rate = 100*sugar/(sugar+ w)
          if rate > max_rate:
            max_rate = rate
            sugar_ans = sugar
            water_ans = sugar + w

print(water_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
import math

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

water = []
max_water_num = int(F / min(A*100,B*100))
#print("max_water_num",max_water_num)
for a_num in range(0,max_water_num+1):
  for b_num in range(0,max_water_num+1):
    w = a_num*A*100 + b_num*B*100
    if w + w/100*E <= F:
      water.append(w)

      
water = set(water)
water = sorted(water)
#print("water candidates", water)

sugar_ans = -1
water_ans  = -1
max_rate = 0

max_sugar_num = int(max(water)/100*E/min(C,D))+1
#print("max_sugar_num", max_sugar_num)
for w in water:
  if not w == 0:
    max_sugar = int(w /100 * E)
    #print(max_sugar)
    #print(min_dif)
    for c_num in range(max_sugar_num+1):
      for d_num in range(max_sugar_num+1):
        sugar = C*c_num + D*d_num
        if max_sugar >= sugar:
          rate = 100*sugar/(sugar+ w)
          if rate > max_rate:
            max_rate = rate
            sugar_ans = sugar
            water_ans = sugar + w

print(water_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
import math

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

water = []
max_water_num = int(F / min(A*100,B*100))
#print("max_water_num",max_water_num)
for a_num in range(0,max_water_num+1):
  for b_num in range(0,max_water_num+1):
    w = a_num*A*100 + b_num*B*100
    if w + w/100*E <= F:
      water.append(w)

      
water = set(water)
water = sorted(water)
#print("water candidates", water)

sugar_ans = -1
water_ans  = -1
max_rate = 0

max_sugar_num = int(max(water)/100*E/min(C,D))+1
#print("max_sugar_num", max_sugar_num)
for w in water:
  if not w == 0:
    max_sugar = int(w /100 * E)
    #print(max_sugar)
    #print(min_dif)
    for c_num in range(max_sugar_num+1):
      for d_num in range(max_sugar_num+1):
        sugar = C*c_num + D*d_num
        if max_sugar >= sugar:
          rate = 100*sugar/(sugar+ w)
          if rate > max_rate:
            max_rate = rate
            sugar_ans = sugar
            water_ans = sugar + w
            if max_rate == 0:
              break
      else:
        continue
      break
    else:
      continue
    break

print(water_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
import math

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

water = []

for a_num in range(0,31):
  for b_num in range(0,31):
    w = a_num*A*100 + b_num*B*100
    if w <= F:
      water.append(w)

      
water = set(water)
water = sorted(water)
#print(water)

sugar_ans = -1
water_ans  = -1
min_dif = int(max(water)/100*E)
#print("min_dif",min_dif)
for w in water:
  if not w == 0:
    max_sugar = int(w /100 * E)
    #print(max_sugar)
    #print(min_dif)
    for c_num in range(31):
      for d_num in range(31):
        sugar = C*c_num + D*d_num
        if max_sugar >= sugar:
          dif = max_sugar - sugar
          if min_dif > dif:
            #print(min_dif,dif, sugar, c_num, d_num)
            min_dif = dif
            sugar_ans = sugar
            water_ans = sugar + w
            if min_dif == 0:
              break
      else:
        continue
      break
    else:
      continue
    break

print(water_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
import math

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

max_num_water = int(F / min(A*100,B*100))
#print(max_num_water)
water = []

for a_num in range(max_num_water+1):
  for b_num in range(max_num_water+1):
    w = a_num*100 + b_num*100
    if w <= F:
      water.append(w)
      
water = set(water)
water = sorted(water)
#print(water)

sugar_ans = -1
water_ans  = -1
for i, w in enumerate(water):
  max_sugar = int(w * E / 100)
  max_sugar_num = math.ceil(max_sugar / min(C,D))
  #print("w,m_s, m_s_c", w, max_sugar, max_sugar_num)
  min_dif = max_sugar
  #print("max_sugar", max_sugar_num)
  for c_num  in range(max_sugar_num+1):
    for d_num in range(max_sugar_num+1):
      sugar = C*c_num + D*d_num
      if sugar <= max_sugar:
        dif = max_sugar - sugar 
        if min_dif > dif:
          min_dif = dif
          sugar_ans = sugar
          water_ans = w + sugar
          if min_dif == 0:
          	break
    else:
      continue
    break
  else:
    continue
  break
print(water_ans, sugar_ans)

Submission status: Wrong Answer

Solution code:
# 100(aA + bB) + cC + dD <= F
# cC + dD <= (aA + bB)E
# maximize 100(cD + dD) / (100(aA + bB) + cC + dD)

A, B, C, D, E, F = map(int, input().split())
concentration = 0
ans = (0, 0)
for a in range(31):
    for b in range(31):
        water = 100*(a*A + b*B)
        if water > F:
            break
        for c in range(3001):
            for d in range(3001):
                sugar = c*C + d*D
                if water + sugar == 0:
                    continue
                if water + sugar > F:
                    break
                if sugar > water // 100 * E:
                    break
                conc = 100*sugar / (water + sugar)
                if concentration < conc:
                    concentration = conc
                    ans = (water + sugar, sugar)
print(ans[0], ans[1])

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxx=0
s=0
t=0
for i in range(F//(100*B)+1):
    for j in range((F-i*100*B)//(100*A)+1):
        for k in range(((i*B+j*A)*E)//D+1):
            for l in range (((i*B+j*A)*E-k*D)//C+1):
                if i==0 and j==0 and k==0 and l==0:
                    s=A
                    continue
                if (100*(i*B+j*A)+k*D+l*C)>F:
                    break
                elif (k*D+l*C)/(k*D+l*C+100*(i*B+j*A))>maxx:
                    maxx=(k*D+l*C)/(k*D+l*C+100*(i*B+j*A))
                    s=(k*D+l*C+100*(i*B+j*A))
                    t=k*D+l*C

print(s,t)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxx=0
s=0
t=0
for i in range(F//(100*B)+1):
    for j in range((F-i*100*B)//(100*A)+1):
        for k in range(((i*B+j*A)*E)//D+1):
            for l in range (((i*B+j*A)*E-k*D)//C+1):
                if i==0 and j==0 and k==0 and l==0:
                    s=1
                    continue
                if (100*(i*B+j*A)+k*D+l*C)>F:
                    break
                elif (k*D+l*C)/(k*D+l*C+100*(i*B+j*A))>maxx:
                    maxx=(k*D+l*C)/(k*D+l*C+100*(i*B+j*A))
                    s=(k*D+l*C+100*(i*B+j*A))
                    t=k*D+l*C

print(s,t)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxx=0
s=0
t=0
for i in range(F//(100*B)+1):
    for j in range((F-i*100*B)//(100*A)+1):
        for k in range(((i*B+j*A)*E)//D+1):
            for l in range (((i*B+j*A)*E-k*D)//C+1):
                if i==0 and j==0 and k==0 and l==0:
                    continue
                if (100*(i*B+j*A)+k*D+l*C)>F:
                    break
                elif (k*D+l*C)/(k*D+l*C+100*(i*B+j*A))>maxx:
                    maxx=(k*D+l*C)/(k*D+l*C+100*(i*B+j*A))
                    s=(k*D+l*C+100*(i*B+j*A))
                    t=k*D+l*C

print(s,t)

Submission status: Wrong Answer

Solution code:
def make_candidate(x,y,limit):
    candidate = []
    q = [x,y]
    while q:
        can = q.pop(0)
        if can <= limit:
            candidate.append(can)
            q += [can+x,can+y]
            q = list(set(q))
    return list(set(candidate))

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

sugar_list = make_candidate(c,d,f*e/(100+e))
for sugar in sugar_list[::-1]:
    water_list = make_candidate(a*100,b*100,f-sugar)
    for water in water_list:
        if water>= sugar*(100/e):
            print(water+sugar, sugar)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A,B,C,D,E,F=MI()
    #dp[i][j]はi*100gのみずにjgの砂糖
    N=F//100+1
    dp=[[0]*(F+1) for _ in range(N)]
    
    dp[0][0]=1
    ansd=0
    ans=[100,0]
    
    AB=[A,B]
    CD=[C,D]
    
    for i in range(N):
        if dp[i][0]==1:
            for k in range(2):
                ii=i+AB[k]
                if ii<N:
                    dp[ii][0]=1
        for j in range(F+1):
            if dp[i][j]==1:
                for k in range(2):
                    jj=j+CD[k]
                    if jj<=F and i*100+jj<=F and jj<=E*i:
                        dp[i][jj]=1
                        d=jj/(100*i+jj)
                        if d>ansd:
                            ans=[100*i+jj,jj]
                            ansd=d
    print(' '.join(map(str, ans)))
    

    

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A,B,C,D,E,F=MI()
    #dp[i][j]はi*100gのみずにjgの砂糖
    N=F//100+1
    dp=[[0]*(F+1) for _ in range(N)]
    
    dp[0][0]=1
    ansd=0
    ans=[0,0]
    
    AB=[A,B]
    CD=[C,D]
    
    for i in range(N):
        if dp[i][0]==1:
            for k in range(2):
                ii=i+AB[k]
                if ii<N:
                    dp[ii][0]=1
        for j in range(F+1):
            if dp[i][j]==1:
                for k in range(2):
                    jj=j+CD[k]
                    if jj<=F and i*100+jj<=F and jj<=E*i:
                        dp[i][jj]=1
                        d=jj/(100*i+jj)
                        if d>ansd:
                            ans=[100*i+jj,jj]
                            ansd=d
    print(' '.join(map(str, ans)))
    

    

main()

Submission status: Wrong Answer

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

# 最初に水の入れ方の組み合わせを考える
water = []
for i in range(f//a+1):
    for j in range(f//b+1):
        if a*i + b*j <= f and not (i == 0 and j == 0):
            water.append(a*i + b*j)
water = list(set(water))
            
# 各組み合わせに対して砂糖を入れられる最大量
sugar = []
for w in water:
    sugar.append(min(f - w, (w//100)*e))
    
# 全探索
ans = []
max_conc = 0
for w, s in zip(water, sugar):
    for i in range(s//c+1):  # 砂糖をc*i(g)入れる
        j = (s - c*i)//d  # d(g)入れられるだけ入れる
        cap = (c*i+d*j)  # 砂糖の量
        if (cap / (w + cap))*100 > max_conc:
            max_conc = (cap / (w + cap))*100
            ans = [w+cap, cap]
            
print(*ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
ans1 = 0
ans2 = 0

for a in range(math.ceil(F / (A*100))+1):
  for b in range(math.ceil(F / (B*100))+1):
    for c in range(1000):
      for d in range(1000):
        if a == 0 and b == 0 and c == 0 and d == 0:
          continue
        
        if 100*A*a + 100*B*b + C*c + D*d > F:
          continue

        if (C*c)+(D*d) > E * (A*a+B*b):
          continue

        tmp = (C*c+D*d)*100 / (100*A*a + 100*B*b + C*c + D*d)
        if tmp > ans:
          ans = tmp
          ans1 = 100*A*a + 100*B*b + C*c + D*d
          ans2 = C*c + D*d

if ans2 == 0:
  print("{0} {1}".format(A, ans2))
else:
  print("{0} {1}".format(ans1, ans2))

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
ans1 = 0
ans2 = 0

for a in range(math.ceil(F / (A*100))+1):
  for b in range(math.ceil(F / (B*100))+1):
    for c in range(1000):
      for d in range(1000):
        if a == 0 and b == 0 and c == 0 and d == 0:
          continue
        
        if 100*A*a + 100*B*b + C*c + D*d > F:
          continue

        if (C*c)+(D*d) > E * (A*a+B*b):
          continue

        tmp = (C*c+D*d)*100 / (100*A*a + 100*B*b + C*c + D*d)
        if tmp > ans:
          ans = tmp
          ans1 = 100*A*a + 100*B*b + C*c + D*d
          ans2 = C*c + D*d

print("{0} {1}".format(ans1, ans2))

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
ans1 = 0
ans2 = 0

for a in range(math.ceil(F / (A*100))+1):
  for b in range(math.ceil(F / (B*100))+1):
    for c in range(300):
      for d in range(300):
        if a == 0 and b == 0 and c == 0 and d == 0:
          continue
        
        if 100*a + 100*b + C*c + D*d > F:
          continue

        if (C*c)+(D*d) > E * (a+b):
          continue

        tmp = (C*c+D*d)*100 / (100*a + 100*b + C*c + D*d)
        if tmp > ans:
          ans = tmp
          ans1 = 100*a + 100*b + C*c + D*d
          ans2 = C*c + D*d

print("{0} {1}".format(ans1, ans2))

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
ans1 = 0
ans2 = 0
count = 0

for a in range(math.ceil(F / (A*100))+1):
  for b in range(math.ceil(F / (B*100))+1):
    for c in range(math.ceil(F / C)+1):
      if a == 0 and b == 0:
        continue

      s = math.floor((E * (a+b) - C*c) / D)
      k = math.floor((F - (100*a + 100*b + C*c)) / D)

      d = min(s, k)
      tmp = (C*c+D*d)*100 / (100*a + 100*b + C*c + D*d)
      if tmp > ans:
        ans = tmp
        ans1 = 100*a + 100*b + C*c + D*d
        ans2 = C*c + D*d

print("{0} {1}".format(ans1, ans2))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b, c, d, e, f = LI()
ret = 0
ans = (0, 0)
for ai in range(f // (100 * a) + 1):
    for bi in range((f - ai * a) // (100 * b) + 1):
        limit = (ai * a + bi * b) * e
        for ci in range(limit // c + 1):
            di = (limit - ci * c) // d
            all_sum = ai * a * 100 + bi * b * 100 + ci * c + di * d
            sugar_sum = ci * c + di * d
            if all_sum and sugar_sum / all_sum > ret and all_sum <= f:
                ret = sugar_sum / all_sum
                ans = (all_sum, sugar_sum)



print(*ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b, c, d, e, f = LI()
ret = 0
ans = (0, 0)
for ai in range(f // (100 * a) + 1):
    for bi in range((f - ai * a) // (100 * b) + 1):
        limit = (ai * a + bi * b) * e
        for ci in range(limit // c + 1):
            di = (limit - ci * c) // d
            all_sum = ai * a * 100 + bi * b * 100 + ci * c + di * d
            sugar_sum = ci * c + di * d
            if all_sum and sugar_sum / all_sum > ret and all_sum < f:
                ret = sugar_sum / all_sum
                ans = (all_sum, sugar_sum)



print(*ans)

Submission status: Wrong Answer

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

best_sugarwater=0
best_sugar=0

max_A=F//(A*100)
for a in range(max_A+1):
    max_B=(F-100*A*a)//(B*100)
    for b in range(max_B+1):
        water=A*a+B*b
        max_sugar=min(F-water*100,water*E)
        max_c=max_sugar//C
        for c in range(max_c+1):
            max_d=(max_sugar-C*c)//D
            for d in range(max_d+1):
                sugar=C*c+D*d
                sugarwater=water*100+sugar
                if sugarwater==0:
                    pass
                elif sugar/(sugarwater) > max_dencity:
                    max_dencity=sugar/(sugarwater)
                    best_sugarwater=sugarwater
                    best_sugar=sugar
                    
                
print(best_sugarwater,best_sugar)

Submission status: Wrong Answer

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

xy = []
for Ai in range(0,F+1,100*A):
    for Bj in range(0,F-Ai+1,100*B):
        x = Ai + Bj
        for Ci in range(0,(F-x)+1,C):
            Dj = 0
            y = Ci + Dj
            while x + y <= F:
                xy.append((x,y))
                Dj += D
                y += D

ans = (0,0)
node = 0
for x,y in xy:
    if x == y == 0:
        continue
    if (x//100) * E >= y:
        tmp = 100*y/(x+y)
        if node < tmp:
            ans = (x+y, y)
            node = tmp

print(*ans)

Submission status: Wrong Answer

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

a = 0
b = 0
c = 0
for s in range(F//A+2):
    for t in range(F//B+2):
        tempa = 100*(s*A + t*B)
        if tempa >= F or tempa == 0:
            continue
        for u in range((F-tempa)//C+2):
            for v in range((F-tempa)//D+2):
                tempb = u*C+v*D
                if tempa+tempb > F:
                    continue
                if tempb/(tempa+tempb) > E/(100+E):
                    continue
                if c < tempb/(tempa+tempb):
                    a = tempa
                    b = tempb
                    c = tempb/(tempa+tempb)
if a+b == 0:
    a = F
print(a+b, b)

Submission status: Wrong Answer

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

a = 0
b = 0
c = 0
for s in range(F//A+2):
    for t in range(F//B+2):
        tempa = 100*(s*A + t*B)
        if tempa >= F or tempa == 0:
            continue
        for u in range((F-tempa)//C+2):
            for v in range((F-tempa)//D+2):
                tempb = u*C+v*D
                if tempa+tempb > F:
                    continue
                if 100*tempb/(tempa+tempb) > 100*E/(100+E):
                    continue
                if c < 100*tempb/(tempa+tempb):
                    a = tempa
                    b = tempb
                    c = 100*tempb/(tempa+tempb)
print(a+b, b)

Submission status: Wrong Answer

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

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

ans = [0, 0, -1]

for x in range((30 // A) + 1):
    for y in range((30 // B) + 1):
        if 100 * (A * x + B * y) > F or x + y == 0:
            continue
        a = 100 * (A * x + B * y)
        for z in range(1 + ((a // 100) * E) // C):
            b = C * z + D * (((a // 100) * E - C * z) // D)
            if b + a > F or b > (a // 100) * E:
                b = 0
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]
        for z in range(1 + ((a // 100) * E) // D):
            b = D * z + C * (((a // 100) * E - D * z) // C)
            if b + a > F or b > (a // 100) * E:
                b = 0
            if b / (a + b) > ans[-1]:
                ans = [a + b, b, b / (a + b)]

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