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

dp=[[False]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 100*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=True

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

for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and i+j<f+1:
            if 0<=i+c+j<f+1:
                dp[i+c][j]=True
            if 0<=i+d+j<f+1:
                dp[i+d][j]=True

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and tmp<conc(j,i)<=limit and j+i<f+1:
            tmp=conc(j,i)
            tmpi=i
            tmpj=j
        if tmp==limit:
            break
        

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

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

def conc(water,sugar):
    return 100*sugar/(water+sugar)

lim=conc(100,e)

water=[]
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 0<100*a*i+100*b*j<f+1:
            water.append(100*a*i+100*b*j)
water=list(set(water))

sugar=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        if 0<c*i+d*j<f+1:
            sugar.append(c*i+d*j)
sugar=list(set(sugar))

tmp=0
tmpw=0
tmps=0
for w in water:
    for s in sugar:
        if 0<w+s<f+1 and tmp<conc(w,s)<=lim:
            tmp=conc(w,s)
            tmpw=w
            tmps=s
        if tmp==lim:
            break

print(tmpw+tmps, tmps)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
def conc(water,sugar):
    return 100*sugar/(water+sugar)
    
lim=conc(100,e)
water=[]
for i in range(f//(100*a)+1):
    for j in range(f//(100*b)+1):
        if 0<100*a*i+100*b*j<f+1:
            water.append(100*a*i+100*b*j)
water=list(set(water))

sugar=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j<f+1:
            sugar.append(c*i+d*j)
sugar=list(set(sugar))

tmp=0
tmpw=0
tmps=0
for w in water:
    for s in sugar:
        if 0<w+s<f+1 and tmp<conc(w,s)<=lim:
            tmp=conc(w,s)
            tmpw=w
            tmps=s

print(tmpw+tmps, tmps)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
def conc(water,sugar):
    return sugar/(water+sugar)
lim=conc(100,e)
water=[]
for i in range(f//(100*a)+2):
    for j in range(f//(100*a)+2):
        if 0<100*a*i+100*b*j<f+1:
            water.append(100*a*i+100*b*j)
water=list(set(water))

sugar=[]
for i in range(f//c+2):
    for j in range(f//d+2):
        if c*i+d*j<f+1:
            sugar.append(c*i+d*j)
sugar=list(set(sugar))

tmp=0
tmpw=0
tmps=0
for w in water:
    for s in sugar:
        if 0<w+s<f+1 and tmp<conc(w,s)<=lim+0.0000000001:
            tmp=conc(w,s)
            tmpw=w
            tmps=s

print(tmpw+tmps, tmps)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
def conc(water,sugar):
    return 10000000000000000*sugar//(water+sugar)
lim=conc(100,e)
water=[]
for i in range(f//(100*a)+2):
    for j in range(f//(100*a)+2):
        if 0<100*a*i+100*b*j<f+1:
            water.append(100*a*i+100*b*j)
water=list(set(water))

sugar=[]
for i in range(f//c+2):
    for j in range(f//d+2):
        if c*i+d*j<f+1:
            sugar.append(c*i+d*j)
sugar=list(set(sugar))

tmp=0
tmpw=0
tmps=0
for w in water:
    for s in sugar:
        if w+s<f+1 and tmp<conc(w,s)<=lim:
            tmp=conc(w,s)
            tmpw=w
            tmps=s

print(tmpw+tmps, tmps)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
def conc(water,sugar):
    return 100*sugar/(water+sugar)
lim=conc(100,e)
water=[]
for i in range(f//(100*a)+2):
    for j in range(f//(100*a)+2):
        if 0<100*a*i+100*b*j<f+1:
            water.append(100*a*i+100*b*j)
water=list(set(water))

sugar=[]
for i in range(f//c+2):
    for j in range(f//d+2):
        if c*i+d*j<f+1:
            sugar.append(c*i+d*j)
sugar=list(set(sugar))

tmp=0
tmpw=0
tmps=0
for w in water:
    for s in sugar:
        if w+s<f+1 and tmp<conc(w,s)<=lim+0.001:
            tmp=conc(w,s)
            tmpw=w
            tmps=s

print(tmpw+tmps, tmps)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
def conc(water,sugar):
    return 100*sugar/(water+sugar)
lim=conc(100,e)
water=[]
for i in range(f//(100*a)+2):
    for j in range(f//(100*a)+2):
        if 0<100*a*i+100*b*j<f+1:
            water.append(100*a*i+100*b*j)
water=list(set(water))

sugar=[]
for i in range(f//c+2):
    for j in range(f//d+2):
        if c*i+d*j<f+1:
            sugar.append(c*i+d*j)
sugar=list(set(sugar))

tmp=0
tmpw=0
tmps=0
for w in water:
    for s in sugar:
        if w+s<f+1 and tmp<conc(w,s)<=lim:
            tmp=conc(w,s)
            tmpw=w
            tmps=s

print(tmpw+tmps, tmps)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
def conc(water,sugar):
    return 100*sugar/(water+sugar)
lim=conc(100,e)
water=[]
for i in range(f//(100*a)+2):
    for j in range(f//(100*a)+2):
        if 0<100*a*i+100*b*j<f+1:
            water.append(100*a*i+100*b*j)
water=list(set(water))

sugar=[]
for i in range(f//c+2):
    for j in range(f//d+2):
        if 0<c*i+d*j<f+1:
            sugar.append(c*i+d*j)
sugar=list(set(sugar))

tmp=0
tmpw=0
tmps=0
for w in water:
    for s in sugar:
        if w+s<f+1 and tmp<conc(w,s)<=lim:
            tmp=conc(w,s)
            tmpw=w
            tmps=s

print(tmpw+tmps, tmps)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
def conc(water,sugar):
    return 100*sugar/(water+sugar)
lim=conc(100,e)
water=[]
for i in range(f//(100*a)+1):
    for j in range(f//(100*a)+1):
        if 0<100*a*i+100*b*j<f+1:
            water.append(100*a*i+100*b*j)
water=list(set(water))

sugar=[]
for i in range(f//c+1):
    for j in range(f//d+1):
        if 0<c*i+d*j<f+1:
            sugar.append(c*i+d*j)
sugar=list(set(sugar))

tmp=0
tmpw=0
tmps=0
for w in water:
    for s in sugar:
        if w+s<f+1 and tmp<conc(w,s)<=lim:
            tmp=conc(w,s)
            tmpw=w
            tmps=s

print(tmpw+tmps, tmps)

Submission status: Wrong Answer

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

dp=[[False]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 100*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=True

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

for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and i+j<f+1:
            if 0<=i+c+j<f+1:
                dp[i+c][j]=True
            if 0<=i+d+j<f+1:
                dp[i+d][j]=True

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and tmp<conc(j,i)<=limit and j+i<f+1:
            tmpi=i
            tmpj=j

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

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

dp=[[False]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 10000000000*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=True

for i in range(f+1):
    for j in range(f+1):
        if dp[i][j] and i+j<f+1:
            if 0<=i+j+100*a<f+1:
                dp[i][j+100*a]=True
            if 0<=i+j+100*b<f+1:
                dp[i][j+100*b]=True
            if 0<=i+c+j<f+1:
                dp[i+c][j]=True
            if 0<=i+d+j<f+1:
                dp[i+d][j]=True

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and tmp<conc(j,i)<=limit and j+i<f+1:
            tmpi=i
            tmpj=j

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[[False]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 10000000000*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=True

for i in range(f+1):
    for j in range(f+1):
        if dp[i][j] and i+j<f+1:
            if 0<=i+j+100*a<f+1:
                dp[i][j+100*a]=True
            if 0<=i+j+100*b<f+1:
                dp[i][j+100*b]=True
            if 0<=i+c+j<f+1:
                dp[i+c][j]=True
            if 0<=i+d+j<f+1:
                dp[i+d][j]=True

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and tmp<conc(j,i)<=limit:
            tmpi=i
            tmpj=j

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[[False]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 100*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=True

for i in range(f+1):
    for j in range(f+1):
        if dp[i][j] and i+j<f+1:
            if 0<=i+j+100*a<f+1:
                dp[i][j+100*a]=True
            if 0<=i+j+100*b<f+1:
                dp[i][j+100*b]=True
            if 0<=i+c+j<f+1:
                dp[i+c][j]=True
            if 0<=i+d+j<f+1:
                dp[i+d][j]=True

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and tmp<conc(j,i)<=limit:
            tmpi=i
            tmpj=j

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[[None]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 100*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=0

for i in range(f+1):
    for j in range(f+1):
        if dp[i][j]!=None and i+j<f+1:
            if 0<=i+j+100*a<f+1:
                dp[i][j+100*a]=(conc(j+100*a,i) if conc(j+100*a,i)<=limit else None)
            if 0<=i+j+100*b<f+1:
                dp[i][j+100*b]=(conc(j+100*b,i) if conc(j+100*b,i)<=limit else None)
            if 0<=i+c+j<f+1:
                dp[i+c][j]=(conc(j,i+c) if conc(j,i+c)<=limit else None)
            if 0<=i+d+j<f+1:
                dp[i+d][j]=(conc(j,i+d) if conc(j,i+d)<=limit else None)

tmp=0
tmpi=0
tmpj=0
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j]!=None and dp[i][j]>tmp:
            tmpi=i
            tmpj=j

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[[None]*(f+1) for i in range(f+1)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

def conc(water,sugar):
    return 100*sugar/(water+sugar)

limit=conc(100,e)
dp[0][0]=0

for i in range(f+1):
    for j in range(f+1):
        if dp[i][j]!=None and i+j<f+1:
            if 0<=i+j+100*a<f+1:
                dp[i][j+100*a]=(conc(j+100*a,i) if conc(j+100*a,i)<=limit else None)
            if 0<=i+j+100*b<f+1:
                dp[i][j+100*b]=(conc(j+100*b,i) if conc(j+100*b,i)<=limit else None)
            if 0<=i+c+j<f+1:
                dp[i+c][j]=(conc(j,i+c) if conc(j,i+c)<=limit else None)
            if 0<=i+d+j<f+1:
                dp[i+d][j]=(conc(j,i+d) if conc(j,i+d)<=limit else None)

tmp=0
tmpi=0
tmpj=0
for i in range(1,f+1):
    for j in range(1,f+1):
        if dp[i][j]!=None and dp[i][j]>tmp:
            tmpi=i
            tmpj=j

print(tmpi+tmpj, tmpi)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
a,b,e = 100*a,100*b,e/(100+e)
best = [0,0,0] #[sugarwater,sugar,concentration]
for n in range(f//a+1):
    na = n*a
    for m in range((f-na)//b+1):
        if n==m==0:
            continue
        mb = m*b
        for k in range((f-na-mb)//c+1):
            kc = k*c
            for l in range((f-na-mb-kc)//d+1):
                ld = l*d
                sugar = (kc+ld)
                sugarwater = (na+mb+kc+ld)
                if best[2] < sugar/sugarwater <= e and sugarwater<=f:
                    best = [sugarwater,sugar,sugar/sugarwater]
                
best.pop()
print(*best)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
a,b,e = 100*a,100*b,e/(100+e)
best = [0,0,0] #[sugarwater,sugar,concentration]
for n in range(f//a+1):
    na = n*a
    for m in range((f-na)//b+1):
        if n==m==0:
            continue
        mb = m*b
        for k in range((f-na-mb)//c+1):
            kc = k*c
            for l in range((f-na-mb-kc)//d+1):
                ld = l*d
                sugar = (kc+ld)
                sugarwater = (na+mb+kc+ld)
                if best[2] < sugar/sugarwater <= e:
                    best = [sugarwater,sugar,sugar/sugarwater]
                
best.pop()
print(*best)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    water = set()
    for a in range(F // (A * 100) + 1):
        for b in range(F // (B * 100) + 1):
            if 0 < a * 100 * A + b * 100 * B <= F:
                water.add(a * 100 * A + b * 100 * B)

    kouho = []
    for w in water:
        ma = (E * w) // 100
        for c in range(ma // C + 1):
            for d in range(ma // D + 1):
                sugar = c * C + d * D
                if sugar <= ma and w + sugar <= F:
                    kouho.append([w, sugar])

    if len(kouho) == 0:
        print(list(water)[0], 0)
        exit()

    max_noudo = 0
    res = []
    for w, sugar in kouho:
        noudo = sugar / (w + sugar)
        if max_noudo < noudo:
            max_noudo = noudo
            res = [w + sugar, sugar]
    print(*res)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
"""
100a 水 <= 30
100b 水 <= 30
c 砂糖 <= 30
d 砂糖 <= 30
e 100gにとける砂糖の量
f 最大質量

全探索の時間ですか！？ 高々 30*30*1000*1000 工夫っすれば  oK.
"""
ans = 0
ansl = [0, 0]
for a_times in range(f//(a*100) + 1):
	a_g = a_times * a * 100
	for b_times in range(f//(b*100) + 1):
		b_g = b_times * b * 100
		for c_times in range(f//c + 1):
			c_g = c_times * c
			for d_times in range(f//d + 1):
				d_g = d_times * d
				targ = a_g+b_g+c_g+d_g
				if targ > f:
					break
				elif targ != 0:
					if (a_g+b_g)//100*e >= c_g+d_g:
						if (c_g+d_g)/targ > ans:
							ans = (c_g+d_g)/targ
							ansl = [targ, c_g+d_g]
print(*ansl)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
ws = []
for i in range(f//100//a+1):
    for j in range(f//100//b+1):
        w = 100*(a*i+b*j)
        if 0 < w < f:
            ws.append(w)
        if w >= f:
            break
ss = []
for i in range(f*e//(100+e)//c+1):
    for j in range(f*e//(100+e)//d+1):
        s = c*i+d*j
        if 0 <= s < f-100*a:
            ss.append(s)
n = []
for w in ws:
    for s in ss:
        if w+s > f:
            continue
        if s > e*w//100:
            continue
        n.append((s/(w+s), w+s, s))

nmax = max(n, key=lambda x:x[0])
print(nmax[1], nmax[2])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
ws = []
for i in range(f//100//a+1):
    for j in range(f//100//b+1):
        w = 100*(a*i+b*j)
        if 0 < w < f:
            ws.append(w)
        if w >= f:
            break

ss = []
for i in range((f-100*a)//c+1):
    for j in range((f-100*a)//d+1):
        s = c*i+d*j
        if 0 <= s < f-100*a:
            ss.append(s)

n = []
for w in ws:
    for s in ss:
        if w+s > f:
            continue
        if s > e*w//100:
            continue
        n.append((s/(w+s), w+s, s))

nmax = max(n, key=lambda x:x[0])
print(nmax[1], nmax[2])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from queue import deque

def main():
  l = list(map(int, input().split()))
  w1, w2, s1, s2, spwr, mm = l
  w1, w2 = 100*w1, 100*w2
  flags = numpy.zeros((mm+1, mm+1))
  dq = deque([(0, 0)])
  max_conc = 0.0
  ans = (w1, 0)
  while dq:
    w, s = dq.pop()
    flags[w, s] = 1
    if w != 0 and s / w * 100 <= spwr:
      conc = 100.0 * s / (w + s)
      if max_conc < conc:
        max_conc = conc
        ans = (w+s, s)
    for sx in [s1, s2]:
      if w + s+sx <= mm and flags[w, s+sx] == 0:
        flags[w, s+sx] = 1
        dq.append((w, s+sx))
    for wx in [w1, w2]:
      if w+wx + s <= mm and flags[w+wx, s] == 0:
        flags[w+wx, s] = 1
        dq.append((w+wx, s))
  print('{} {}'.format(*ans))
    

if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from queue import deque

def main():
  l = list(map(int, input().split()))
  w1, w2, s1, s2, spwr, mm = l
  w1, w2 = 100*w1, 100*w2
  flags = numpy.zeros((mm+1, mm+1))
  dq = deque([(0, 0)])
  max_conc = 0.0
  ans = (0, 0)
  while dq:
    w, s = dq.pop()
    flags[w, s] = 1
    if w != 0 and s / w * 100 <= spwr:
      conc = 100.0 * s / (w + s)
      if max_conc < conc:
        max_conc = conc
        ans = (w+s, s)
    for sx in [s1, s2]:
      if w + s+sx <= mm and flags[w, s+sx] == 0:
        flags[w, s+sx] = 1
        dq.append((w, s+sx))
    for wx in [w1, w2]:
      if w+wx + s <= mm and flags[w+wx, s] == 0:
        flags[w+wx, s] = 1
        dq.append((w+wx, s))
  print('{} {}'.format(*ans))
    

if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int, input().split())
sugar = []
for i in range(1501):
    if (i%c==0):
        sugar.append(i)
    else:
        for j in range(i//c+1):
            if (i-j*c)%d==0:
                sugar.append(i)
#print(sugar)
ans = 0
ax = a
ay = 0
for i in range(30):
    for j in range(30):
        if (i==0 and j==0):
            continue
        if (a*i+b*j <= f//100):
            w = (a*i+b*j)*100
            for k in sugar:
                if ((100*k)/(w+k)<=(100*e)/(100+e) and (w+k)<=f):
                    if ((100*k)/(w+k) > ans):
                        
                        ans = 100*k/(w+k)
                        #print(w,k,ans)
                        ax = w
                        ay = k
print(ax+ay,ay)

Submission status: Wrong Answer

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

# 作れる水の量を全探索（せいぜい30種類）
# 各水の量に対して、溶かせる砂糖の最大値は決まる（DPする）
# 最大値とすることができる砂糖に最も近づいたら割合を求め、答えの最大値を更新する

A,B,C,D,E,F = map(int,readline().split())
max_rate = 0
ans_water = 0
ans_sugar = 0
for a in range(30):
  for b in range(30):
    if a * A * 100 + b * B * 100 >= F:
      continue
    water = a * A * 100 + b * B * 100
    if water == 0:
      continue
    max_sugar = water * E // 100 # 溶ける砂糖の最大値
    if max_sugar + water > F:
      max_sugar = F - water
      
    dp = [False] * (max_sugar + 1)
    dp[0] = True
    for i in range(len(dp)):
      if dp[i]:
        if i + C >= len(dp):
          break
        dp[i + C] = True
    
    for i in range(len(dp)):
      if dp[i]:
        if i + D >= len(dp):
          break
        dp[i + D] = True
        
    for i in range(len(dp) - 1, -1, -1):
      if dp[i]:
        rate = (i * 100) / (water + i)
        break
    if rate > max_rate:
      max_rate = rate
      ans_water = water
      ans_sugar = i
    
print(ans_water + ans_sugar,ans_sugar)

Submission status: Wrong Answer

Solution code:
a , b , c , d , e , f = map(int,input().split())
midp = [-1 for i in range(f+1)]
mizu = []
midp[0] = 0
for i in range(f+1):
    if midp[i] != -1:
        if i + a*100 <= f and midp[i+a*100] != 0:
            midp[i+a*100] = 0
            mizu.append(i+a*100)
        if i + b*100 <= f and midp[i+b*100] != 0:
            midp[i+b*100] = 0
            mizu.append(i+b*100)
ans = 0
cou = [-1,-1]
for i in mizu:
    sai = i*e//100
    sadp = [-1 for f in range(sai+1)]
    sadp[0] = 0
    maxsa = 0
    for j in range(sai+1):
        if sadp[j] != -1:
            if j + c <= sai and i + j + c <= f and sadp[j+c] != 0:
                sadp[j+c] = 0
                maxsa = max(maxsa,j+c)
            if j + d <= sai and i + j + d <= f and sadp[j+d] != 0:
                sadp[j+d] = 0
                maxsa = max(maxsa,j+d)
    if ans < maxsa/(i+maxsa):
        ans = maxsa/(i+maxsa)
        cou = [i+maxsa,maxsa]

print(*cou)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxim=0
ans=[0,0]
for i in range(F//100//A+2):
  for j in range(F//100//B+2):
    if A*100*i+B*100*j >= F:
      break
    for k in range(F//C+2):
      if A*100*i+B*100*j+C*k >= F:
        break
      for l in range(F//D+2):
        s=D*l+C*k
        w=A*100*i+B*100*j
        if s+w<=F:
          if w//100*E>=s:
            if s+w!=0:
              if maxim<100*s/(s+w):
                maxim=100*s/(s+w)
                ans=[w+s,s]
print(*ans)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxim=0
ans=[0,0]
for i in range(F//100//A+1):
  for j in range(F//100//B+1):
    if A*100*i+B*100*j >= F:
      break
    for k in range(F//C+1):
      if A*100*i+B*100*j+C*k >= F:
        break
      for l in range(F//D+1):
        s=D*l+C*k
        w=A*100*i+B*100*j
        if s+w<=F:
          if w//100*E>=s:
            if s!=0:
              if maxim<=100*s/(s+w):
                maxim=100*s/(s+w)
                ans=[w+s,s]
print(*ans)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
maxim=0
L=[0,0,0]
ans=[0,0]
for i in range(F//100//A+1):
  L[0]=A*100*i
  for j in range((F-(L[0]))//100//B+1):
    L[1]=A*100*i+B*100*j
    for k in range((F-(L[1]))//C+1):
      L[2]=C*k+A*100*i+B*100*j
      for l in range((F-(L[2]))//D+1):
        s=D*l+C*k
        w=A*100*i+B*100*j
        if w//100*E>=s:
          if s!=0:
            if maxim<=100*s/(s+w):
              maxim=100*s/(s+w)
              ans=[w+s,s]
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
	A, B, C, D, E, F = NMI()
	W = []
	for i in range(31):
		for j in range(16):
			if 0 < (A*i + B*j) * 100 <= F:
				W.append(A*i + B*j)
	W = set(W)
	S = set()
	for i in range(3001):
		if C*i > 30 * E:
			break
		for j in range(1501):
			if 0 < C*i + D*j <= 30 * E:
				S.add(C*i + D*j)
	con = 0
	ans = [0, 0]
	for w in W:
		for s in S:
			if s <= F - 100 * w and s <= w * E and 100 * s / w >= con:
				con = 100 * s / w
				ans = [100*w + s, s]
	print(ans[0], ans[1])



if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from heapq import heapify, heappop, heappush
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

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

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

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

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

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

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

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

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

# ここから書き始める
a, b, c, d, e, f = map(int, input().split())
density = 0
ans = [0, 0]
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                s = c * k + d * l
                total = s + 100 * a * i + 100 * b * j
                if total > f or total == 0 or s / total > e / (100 + e):
                    continue
                if s / total > density:
                    density = s / total
                    ans = [total, s]
print(*ans)