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

indxmax=0
wmax=0
emax=0
for ai in range(min(int(f/100/a)+1,31)):
    if ai==0:
        a30=30
    else:
        a30=min(31,int((f-100*a*ai)/100/b)+1)
    for bi in range(a30):
        w=100*a*ai+100*b*bi
#        print("a,b:",ai,bi,w)
        if w<=f:
            for ci in range(min(31,int(w/100*e/c)+1)):
#                di=int((w/100*e-c*ci-1)/d)+1
                di=int((w/100*e-c*ci)/d+10**(-10))
#                print("a,b,c,d*",ai,bi,ci,di,ci*c+di*d)
                if c*ci+d*di<=0:
                    indx=0
                elif w==0:
                    indx=0
                else:
                    indx=(c*ci+d*di)*100/w
#                print("a,b,c,d*,indx",ai,bi,ci,di,ci*c+di*d,indx)
#                print(indxmax<indx ,e-indx>=0.0 ,f-(w+c*ci+d*di)>=0.0)
                if indxmax<indx and e-indx>=0.0 and w+c*ci+d*di<=f:
                    wmax=int(w+c*ci+d*di)
                    indxmax=indx 
                    emax=int(c*ci+d*di)
#                    print("c,d",ci,di,emax,wmax)
print(wmax,emax)

Submission status: Wrong Answer

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

indxmax=0
wmax=0
emax=0
for ai in range(min(int(f/100/a)+1,30)):
    if ai==0:
        a30=30
    else:
        a30=min(30,int((f-100*a*ai)/100/b)+1)
    for bi in range(a30):
        w=100*a*ai+100*b*bi
#        print("a,b:",ai,bi,w)
        if w<=f:
            for ci in range(min(30,int(w/100*e/c)+1)):
#                di=int((w/100*e-c*ci-1)/d)+1
                di=int((w/100*e-c*ci)/d+10**(-10))
#                print("a,b,c,d*",ai,bi,ci,di,ci*c+di*d)
                if c*ci+d*di<=0:
                    indx=0
                elif w==0:
                    indx=0
                else:
                    indx=(c*ci+d*di)*100/w
#                print("a,b,c,d*,indx",ai,bi,ci,di,ci*c+di*d,indx)
#                print(indxmax<indx ,e-indx>=0.0 ,f-(w+c*ci+d*di)>=0.0)
                if indxmax<indx and e-indx>=0.0 and w+c*ci+d*di<=f:
                    wmax=int(w+c*ci+d*di)
                    indxmax=indx 
                    emax=int(c*ci+d*di)
#                    print("c,d",ci,di,emax,wmax)
print(wmax,emax)

Submission status: Wrong Answer

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

indxmax=0
wmax=0
emax=0
for ai in range(min(int(f/100/a)+1,30)):
    if ai==0:
        a30=30
    else:
        a30=min(30,int((f-100*a*ai)/100/b)+1)
    for bi in range(a30):
        w=100*a*ai+100*b*bi
#        print("a,b:",ai,bi,w)
        if w<=f:
            for ci in range(min(30,int(w/100*e/c)+1)):
#                di=int((w/100*e-c*ci-1)/d)+1
                di=int((w/100*e-c*ci)/d)
#                print("a,b,c,d*",ai,bi,ci,di,ci*c+di*d)
                if c*ci+d*di<=0:
                    indx=0
                elif w==0:
                    indx=0
                else:
                    indx=(c*ci+d*di)*100/w
#                print("a,b,c,d*,indx",ai,bi,ci,di,ci*c+di*d,indx)
#                print(indxmax<indx ,e-indx>=0.0 ,f-(w+c*ci+d*di)>=0.0)
                if indxmax<indx and e-indx>=0.0 and w+c*ci+d*di<=f:
                    wmax=w+c*ci+d*di
                    indxmax=indx 
                    emax=c*ci+d*di
#                    print("c,d",ci,di,emax,wmax)
print(wmax,emax)

Submission status: Wrong Answer

Solution code:
#074_C
from bisect import bisect_left, bisect_right
a, b, c, d, e, f = map(int, input().split())
water = set()
sugar = set()
for i in range(30):
    for j in range(30):
        if 0 < (a * i + b * j) * 100 <= f:
            water.add((a * i + b * j) * 100)
for i in range(f//c + 1):
    for j in range(f//d + 1):
        if 0 < (c * i + d * j) <= f:
            sugar.add(c * i + d * j)
water = sorted(list(water))
sugar = sorted(list(sugar))

ans = [100 * a, 0]
for w in water:
    x = w * e // 100
    if bisect_right(sugar, x) == 0:
        continue
        
    s = sugar[bisect_right(sugar, x) - 1]
    if w + s > f:
        continue
    if ans[1] * (s + w) < s * ans[0]:
        ans = [s+w, s]
print(*ans)

Submission status: Wrong Answer

Solution code:
#074_C
from bisect import bisect_left, bisect_right
a, b, c, d, e, f = map(int, input().split())
water = set()
sugar = set()
for i in range(30):
    for j in range(30):
        if 0 < (a * i + b * j) <= f // 100:
            water.add((a * i + b * j) * 100)
for i in range(f//c + 1):
    for j in range(f//d + 1):
        if 0 < (c * i + d * j) <= f:
            sugar.add(c * i + d * j)
water = sorted(list(water))
sugar = sorted(list(sugar))

ans = [100 * a, 0]
for w in water:
    x = w * e // 100
    if bisect_right(sugar, x) == 0:
        continue
        
    s = sugar[bisect_right(sugar, x) - 1]
    if w + s > f:
        continue
    if ans[1] / ans[0] < s / (s + w):
        ans = [s+w, s]
print(*ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[0]*(3000+1)
for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j<=3000:
            dp[c*i+d*j]=c*i+d*j
for i in range(1,3001):
    dp[i]=max(dp[i],dp[i-1])
ans_den=-1
ans_num=-1
ans=0
for i in range(f//a+1):
    for j in range(f//b+1):
        #so we have put 100*a*i +100*b*j amount of water 
        w=100*i*a+100*j*b
        if w>f or w==0:
            continue
        rem=f-w
        sugar_max=min(e*(i*a+j*b),rem)
        val=dp[sugar_max]
        if val/(w+val)>ans:
            ans=val/(w+val)
            ans_num=val
            ans_den=w+val
print(ans_den,ans_num)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
dp=[0]*(3000+1)
dp[c]=c
dp[d]=d
for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j<=3000:
            dp[c*i+d*j]=c*i+d*j
for i in range(1,3001):
    dp[i]=max(dp[i],dp[i-1])
ans_den=-1
ans_num=-1
ans=0
for i in range(f//a+1):
    for j in range(f//b+1):
        #so we have put 100*a*i +100*b*j amount of water 
        w=100*i*a+100*j*b
        if w>f or w==0:
            continue
        rem=f-w
        sugar_max=min(3000,e*(i*a+j*b),rem)
        val=dp[sugar_max]
        if val/w>ans:
            ans=val/w
            ans_num=val
            ans_den=w+val
print(ans_den,ans_num)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

A, B, C, D, E, F = list(map(int,input().split()))
X = []
ans = 1000
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                if 100*A*i+100*B*j+C*k+D*l != 0:
                    if 100*A*i+100*B*j+C*k+D*l <= F and (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l) <= E/(100 + E):
                        ans =(E/(100 + E) - (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l))
                        X.append([ans , 100*A*i+100*B*j+C*k+D*l, C*k+D*l])
X = sorted(X,key=itemgetter(0),reverse = False) 

print(X[0][1],X[0][2])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

A, B, C, D, E, F = list(map(int,input().split()))
X = []
ans = 1000
for i in range(30):
    for j in range(30):
        for k in range(30):
            for l in range(30):
                if 100*A*i+100*B*j+C*k+D*l != 0:
                    if 100*A*i+100*B*j+C*k+D*l <= F :
                        if (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l) <= E/(100 + E):
                            ans =(E/(100 + E) - (C*k+D*l)/(100*A*i+100*B*j+C*k+D*l))
                            X.append([ans , 100*A*i+100*B*j+C*k+D*l, C*k+D*l])
X = sorted(X,key=itemgetter(0),reverse = False) 

print(X[0][1],X[0][2])

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
a *= 100
b *= 100
den = 0
sugar = 0
water = 0
for i in range(0,f+1,a):
    for j in range(0,f-i+1,b):
        for k in range(0,f-i-j+1,c):
            for l in range(0,f-i-j-k+1,d):
                w = i+j
                s = k+l
                if w == 0: break
                if s/w > e/100: continue
                x = s/(w+s)
                if x > den:
                    den = x
                    water = w
                    sugar = s
        else:
            continue
        break
print(sugar+water,sugar)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
a *= 100
b *= 100
den = 0
sugar = 0
water = 0
for i in range(0,f+1,a):
    for j in range(0,f-i+1,b):
        for k in range(0,f-i-j-1,c):
            for l in range(0,f-i-j-k-1,d):
                w = i+j
                s = k+l
                if w == 0: break
                if s/w > e/100: continue
                x = s/(w+s)
                if x > den:
                    den = x
                    water = w
                    sugar = s
        else:
            continue
        break
print(sugar+water,sugar)

Submission status: Wrong Answer

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

water = [False]*(f+1)
suger = [False]*(f+1)

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

ans_w, ans_s = a, 0
for i in range(f+1):
  if water[i] == False:
    continue
  for j in range(f, -1, -1):
    if suger[j] == False or j*(100+e) > (j+i)*e or j+i > f:
      continue
    if j*(ans_w+ans_s) > (j+i)*ans_s:
      ans_w, ans_s = i, j
    break
print(ans_w+ans_s, ans_s)

Submission status: Wrong Answer

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

W = 100
S = 0
for w in water:
    for s in sugar:
        if w == 0 or s == 0: continue
        if w+s > f: continue
        if s*100 > e*w: continue
        if s*(W+S) > S*(w+s):
            W = w
            S = s

print(W+S,S)

Submission status: Wrong Answer

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

W = 0
S = 0
for w in water:
    for s in sugar:
        if w == 0 or s == 0: continue
        if w+s > f: continue
        if s*100 > e*w: continue 
        if s*(W+S) > S*(w+s):
            W = w
            S = s

print(W+S,S)

Submission status: Wrong Answer

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

d = 0
W = 0
S = 0
for w in water:
    for s in sugar:
        if w == 0 or s == 0: continue
        if w+s > f: continue
        if s/w > e/100: continue
        x = s/(w+s) 
        if x > d:
            d = x
            W = w
            S = s

print(W+S,S)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f = map(int,input().split())
water = []
sugar = []
for i in range(f):
    for j in range(f):
        w = a*100*i + b*100*j
        if w <= f: water.append(w)
        s = c*i + d*j
        if s <= f: sugar.append(s)

d = 0
W = 0
S = 0
for w in water:
    for s in sugar:
        if w == 0 or s == 0: continue
        if w+s > f: continue
        if s/w > e/100: continue
        x = s/(w+s) 
        if x > d:
            d = x
            W = w
            S = s

print(W+S,S)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {(a, a):0}
dp[a][0] = a
if b <= f:
    dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
a, b, c, d, e, f = map(int, input().split())
lcm = a*b // gcd(a, b)
X = [100*i for i in range(1, 31) if gcd(i, lcm) != 1]

memo = {(x, 0):0 for x in X}
for x in X:
    for y in range(f):
        if (x, y-c) in memo or (x, y-d) in memo:
            z = x + y
            if z <= f and 100*y <= x*e:
                memo[(x, y)] = y / z
            else:
                break
_, water, sugar = max(((v, x, y) for (x, y), v in memo.items()))
print(water + sugar, sugar)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
a, b, c, d, e, f = map(int, input().split())
lcm = a*b // gcd(a, b)
X = [100*i for i in range(1, 31) if gcd(i, lcm) != 1]
Y = [i for i in range(f) if i % c == 0 or i % d == 0]

memo = {}
for x in X:
    for y in Y:
        z = x + y
        if z <= f and 100*y <= x*e:
            memo[(x, y)] = y / z
        else:
            break
_, water, sugar = max(((v, x, y) for (x, y), v in memo.items()))
print(water + sugar, sugar)

Submission status: Wrong Answer

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

dp = [[0, 0] for _ in range(f+1)]
len(dp)
for x in range(1, f):
    if x+a <= f and dp[x+a][1] <= dp[x][1]:
        dp[x+a][0] = dp[x][0] + a
        dp[x+a][1] = dp[x][1]
    if x+b <= f and dp[x+b][1] <= dp[x][1]:
        dp[x+b][0] = dp[x][0] + b
        dp[x+b][1] = dp[x][1]
    if x+c <= f and dp[x][1] + c <= dp[x][0] * e // 100 and dp[x+c][1] <= dp[x][1] + c:
        dp[x+c][0] = dp[x][0]
        dp[x+c][1] = dp[x][1] + c
    if x+d <= f and dp[x][1] + d <= dp[x][0] * e // 100 and dp[x+d][1] <= dp[x][1] + d:
        dp[x+d][0] = dp[x][0]
        dp[x+d][1] = dp[x][1] + d
water, sugar = max(dp, key=lambda x:x[1]/(x[0]+x[1]) if x[0]+x[1] != 0 else 0)
print(water + sugar, sugar)

Submission status: Wrong Answer

Solution code:
INF=-(10**16)
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*(31)
wDP[0]=True
water=[]
for i in range(1,31):
    if(i>=B and wDP[i-B]):
        wDP[i]=True
    elif(i>=A and wDP[i-A]):
        wDP[i]=True
for i in range(len(wDP)):
    if(wDP[i] and i!=0):
        water.append(i*100)
water=list(set(water))
ans=[water[0],0]
mconc=0
sugar=[]
for x in water:
    sugar.append(min(F-x,(x*E//100)))
for w,s in zip(water,sugar):
    for i in range(s//C+1):
        j=(s-C*i)//D
        cap=(C*i+D*j)
        if(cap/(w+cap))*100>mconc:
            mconc=(cap/(w+cap))*100
            ans=[w+cap,cap]
print(*ans)

Submission status: Wrong Answer

Solution code:
INF=-(10**16)
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*(31)
wDP[0]=True
water=[]
for i in range(1,31):
    if(i>=B and wDP[i-B]):
        wDP[i]=True
        water.append(i*100)
    if(i>=A and wDP[i-A]):
        wDP[i]=True
        water.append(i*100)
water=list(set(water))
ans=[water[0],0]
mconc=0
sugar=[]
for x in water:
    sugar.append(min(F-x,(x*E//100)))
for w,s in zip(water,sugar):
    for i in range(s//C+1):
        j=(s-C*i)//D
        cap=(C*i+D*j)
        if(cap/(w+cap))*100>mconc:
            mconc=(cap/(w+cap))*100
            ans=[w+cap,cap]
print(*ans)

Submission status: Wrong Answer

Solution code:
INF=-(10**16)
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*((F//100)+1)
wDP[0]=True
for i in range(1,F//100+1):
    wDP[i]=True if wDP[i-A] or wDP[i-B] else False
water=[]
for i in range(len(wDP)):
    if(wDP[i] and i!=0):
        water.append(i*100)
ans=[water[0],0]
mconc=0
sugar=[]
for x in water:
    sugar.append(min(F-x,(x*E//100)))
for w,s in zip(water,sugar):
    for i in range(s//C+1):
        j=(s-C*i)//D
        cap=(C*i+D*j)
        if(cap/(w+cap))*100>mconc:
            mconc=(cap/(w+cap))*100
            ans=[w+cap,cap]
print(*ans)

Submission status: Wrong Answer

Solution code:
INF=-(10**16)
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*((F//100)+1)
wDP[0]=True
for i in range(1,F//100+1):
    wDP[i]=True if wDP[i-A] or wDP[i-B] else False
water=[]
for i in range(len(wDP)):
    if(wDP[i] and i!=0):
        water.append(i*100)
ans,mconc=[INF,INF],INF
for x in water:
    up=min(x*E//100,F-x)
    sDP=[0]*(up+1)
    for i in range(1,up+1):
        if(i>=D):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C,sDP[i-D]+D)
        elif(i>=C):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C)
        else:
            sDP[i]=sDP[i-1]
    conc=100*sDP[-1]/(x+sDP[-1])
    if(conc>=mconc):
        mconc=conc;ans[0]=x+sDP[-1];ans[1]=sDP[-1]
if(ans==[INF,INF]):
    print(water[0],0)
else:
    print(*ans)

Submission status: Wrong Answer

Solution code:
INF=-(10**16)
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*((F//100)+1)
wDP[0]=True
for i in range(1,F//100+1):
    wDP[i]=True if wDP[i-A] or wDP[i-B] else False
water=[]
for i in range(len(wDP)):
    if(wDP[i] and i!=0):
        water.append(i*100)
ans,mconc=[INF,INF],INF
for x in water:
    up=min(x*E//100,F-x)
    sDP=[0]*(up+1)
    for i in range(1,up+1):
        if(i>=D):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C,sDP[i-D]+D)
        elif(i>=C):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C)
        else:
            sDP[i]=sDP[i-1]
    conc=100*sDP[-1]/(x+sDP[-1])
    if(conc>=mconc):
        mconc=conc;ans[0]=x+sDP[-1];ans[1]=sDP[-1]
print(*ans)

Submission status: Wrong Answer

Solution code:
INF=-(10**16)
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*((F//100)+1)
wDP[0]=True
for i in range(1,F//100+1):
    wDP[i]=True if wDP[i-A] or wDP[i-B] else False
water=[]
for i in range(len(wDP)):
    if(wDP[i] and i!=0):
        water.append(i*100)
ans,mconc=[INF,INF],INF
for x in water:
    up=min(x*E//100,F-x)
    sDP=[0]*(up+1)
    for i in range(1,up+1):
        if(i>=D):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C,sDP[i-D]+D)
        elif(i>=C):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C)
        else:
            sDP[i]=sDP[i-1]
    if(sDP[-1]==0):
        continue
    conc=100*sDP[-1]/(x+sDP[-1])
    if(conc>=mconc):
        ans=[x,sDP[-1]]
        mconc=conc
print(sum(ans),ans[1])

Submission status: Wrong Answer

Solution code:
INF=-(10**16)
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*((F//100)+1)
wDP[0]=True
for i in range(1,F//100+1):
    wDP[i]=True if wDP[i-A] or wDP[i-B] else False
water=[]
for i in range(len(wDP)):
    if(wDP[i] and i!=0):
        water.append(i*100)
ans1,ans2,ans3=INF,INF,INF
for x in water:
    up=x*E//100 if F-x>=x*E//100 else F-x
    sDP=[0]*(up+1)
    for i in range(1,up+1):
        if(i>=D):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C,sDP[i-D]+D)
        elif(i>=C):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C)
        else:
            sDP[i]=sDP[i-1]
    conc=100*sDP[-1]/(x+sDP[-1])
    if(conc>=ans3):
        ans3=conc;ans1=x+sDP[-1];ans2=sDP[-1]
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*(F//100+1)
wDP[0]=True
for i in range(1,F//100+1):
    wDP[i]=True if wDP[i-A] or wDP[i-B] else False
water=[]
for i in range(len(wDP)):
    if(wDP[i] and i!=0):
        water.append(i*100)
ans1=0;ans2=0;ans3=0
for x in water:
    up=x*E//100 if F-x>=x*E//100 else F-x
    sDP=[0]*(up+1)
    for i in range(1,up+1):
        if(i>=D):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C,sDP[i-D]+D)
        elif(i>=C):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C)
        else:
            sDP[i]=sDP[i-1]
    conc=sDP[up]/(x+sDP[up])*100
    if(conc>=ans3):
        ans3=conc
        ans1=x+sDP[up]
        ans2=sDP[up]
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*(F//100+1)
wDP[0]=True
for i in range(1,F//100+1):
    wDP[i]=True if wDP[i-A] or wDP[i-B] else False
water=[]
for i in range(len(wDP)):
    if(wDP[i] and i!=0):
        water.append(i*100)
ans1=0;ans2=0;ans3=0
for x in water:
    up=x*E//100 if F-x>=x*E//100 else F-x
    sDP=[0]*(up+1)
    for i in range(1,up+1):
        if(i>=D):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C,sDP[i-D]+D)
        elif(i>=C):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C)
        else:
            sDP[i]=sDP[i-1]
    conc=sDP[up]/(x+sDP[up])*100
    print(conc)
    if(conc>=ans3):
        ans3=conc
        ans1=x+sDP[up]
        ans2=sDP[up]
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
A,B,C,D,E,F=map(int,input().split())
waterDP=[False]*(F//100+1)
waterDP[0]=True
for i in range(1,F//100+1):
    waterDP[i]=True if waterDP[i-A] or waterDP[i-B] else False
water=[]
for i in range(len(waterDP)):
    if(waterDP[i] and i!=0):
        water.append(i)
res=0
ans1=0;ans2=0;ans3=0
for x in water:
    up=x*E if F-x*100>=x*E else F-x*100
    sugarDP=[0]*(up+1)
    for i in range(1,up+1):
        if(i>=D):
            sugarDP[i]=max(sugarDP[i-1],sugarDP[i-C]+C,sugarDP[i-D]+D)
        elif(i>=C):
            sugarDP[i]=max(sugarDP[i-1],sugarDP[i-C]+C)
        else:
            sugarDP[i]=sugarDP[i-1]
    if(sugarDP[up]==0):
        continue
    conc=(sugarDP[up]*100)/(100*x+sugarDP[up])
    if(conc>ans3):
        ans3=conc
        ans1=100*x+sugarDP[up]
        ans2=sugarDP[up]
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
import sys

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

water_pattern = []
for i in range(f+1):
    for j in range(f+1):
        x = a*i*100 + b*j*100
        if x <= f and not x in water_pattern:
            water_pattern.append(x)

sugar_pattern = []
for i in range(f+1):
    for j in range(f+1):
        y = c*i + d*j
        if y <= f and not y in sugar_pattern:
            sugar_pattern.append(y)

sugarwater_max = 0
sugar_max = 0
concentration = 0
for i in range(1, len(water_pattern)):
    for j in range(1, len(sugar_pattern)):
            sugarwater = water_pattern[i] + sugar_pattern[j]
            if (water_pattern[i]/100) * e >= sugar_pattern[j] and sugarwater <= f and concentration < 100 * sugar_pattern[j] / sugarwater:
                sugarwater_max = sugarwater
                sugar_max = sugar_pattern[j]
                concentration = 100 * sugar_pattern[j] / sugarwater

print("{} {}".format(sugarwater_max, sugar_max))

Submission status: Wrong Answer

Solution code:
import sys

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

water_pattern = []
for i in range(f+1):
    for j in range(f+1):
        x = a*i*100 + b*j*100
        if x <= f and not x in water_pattern:
            water_pattern.append(x)

sugar_pattern = []
for i in range(f+1):
    for j in range(f+1):
        y = c*i + d*j
        if y <= f and not y in sugar_pattern:
            sugar_pattern.append(y)

sugarwater_max = 0
sugar_max = 0
concentration = 0
for i in range(1, len(water_pattern)):
    for j in range(1, len(sugar_pattern)):
            sugarwater = water_pattern[i] + sugar_pattern[j]
            if (water_pattern[i]/100) * e >= sugar_pattern[j] and sugarwater <= f:
                if sugarwater_max == 0 and sugar_max == 0:
                    sugarwater_max = sugarwater
                    sugar_max = sugar_pattern[j]
                    concentration = 100 * sugar_pattern[j] / sugarwater
                else:
                    if concentration < 100 * sugar_pattern[j] / sugarwater:
                        sugarwater_max = sugarwater
                        sugar_max = sugar_pattern[j]
                        concentration = 100 * sugar_pattern[j] / sugarwater

print("{} {}".format(sugarwater_max, sugar_max))

Submission status: Wrong Answer

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

W = []
for i in range(f+1):
    for j in range(f+1):
        w = a*i + b*j
        if w <= f and w > 0:
            W.append(w)
S = []
for i in range(f+1):
    for j in range(f+1):
        s = c*i + d*j
        if s <= f:
            S.append(s)

cmax = 0
solubility = e/(e+100)
argmax = 0, 0

for w in W:
    for s in S:
        if w+s > f:
            continue

        concentration = s/(w+s)

        if cmax < concentration <= solubility:
            cmax = s/(w+s)
            argmax = w+s, s

print(*argmax)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans=0
tmp=['0','0']
for i in range(1,2**4):
  l=[0]*4
  water=0
  sugar=0
  for j in range(4):
    if i>>j&1:
      l[j]=1
  if l[0]==1:
    water+=100*a
  if l[1]==1:
    water+=100*b
  if water==0:
    pass
  else:
    rest=f-water
    if rest<=0 or (l[2]==l[3]==0):
      pass
    else:
      max_sugar=e*(water//100)
      if l[2]==1 and l[3]==0:
        sugar+=c*(min(rest,max_sugar)//c)
      elif l[3]==1 and l[2]==0:
        sugar+=d*(min(rest,max_sugar)//d)
      elif l[2]==l[3]==1:
        d_max=min(rest,max_sugar)//d
        t=d*d_max
        for i in range(d_max,-1,-1):
          REST=rest-i*d
          Max_sugar=max_sugar-i*d
          t_max=i*d+c*(min(REST,Max_sugar)//c)
          t=max(t,t_max)
        sugar+=t
      tot=sugar+water
      if sugar/tot>ans:
        ans=sugar/tot
        tmp=[str(tot),str(sugar)]         
print(' '.join(tmp))

Submission status: Wrong Answer

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

dp = [[False]*(F-100*i+1) for i in range(F//100+1)]
dp[0][0] = True
dp[A][0] = True

for i in range(A,F//100+1):
    for j in range(C,F-100*i+1):
        if i < B and j < D:
            if (dp[i-A][j] or dp[i][j-C]) and j<=i*E:
                dp[i][j] = True
        elif i >= B and j < D:
            if (dp[i-A][j] or dp[i-B][j] or dp[i][j-C]) and j<=i*E:
                dp[i][j] = True
        elif i < B and j >= D:
            if (dp[i-A][j] or dp[i][j-C] or dp[i][j-D]) and j<=i*E:
                dp[i][j] = True
        else:
            if (dp[i-A][j] or dp[i-B][j] or dp[i][j-C] or dp[i][j-D]) and j<=i*E:
                dp[i][j] = True

#print(dp)
#print(dp[5])
#print(dp[5][500])

mi = 1
mj = 0
for i in range(F//100+1):
    for j in range(F-100*i+1):
        if dp[i][j] and (j*(100*mi+mj) > mj*(100*i+j)):
            mi = i
            mj = j
            #print(mi,mj)
print(100*mi+mj,mj)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
su=[False]*(f+1)
wa=[False]*(f+1)
a*=100
b*=100
e=(100*e)/(100+e)
for i in range(f+1):
    for j in range(f+1):
        if i*c+j*d<=f:
            su[i*c+j*d]=True
        if i*a+j*b<=f:
            wa[i*a+j*b]=True
ans=-1
x,y=a,0
for i in range(1,f+1):
    for j in range(f+1):
        if su[j] and wa[i] and i+j<=f and ans<=100*j/(i+j)<=e:
            x,y=i,j
print(x+y,y)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left 
#bisect_left(a,x):a[i]>=xとなるような最小のi.
#昇順ソートされたリストaに昇順を崩さずxを挿入できる位置s(0-index)を返す.
#a=[1,3,5,7,9,11,13,15,17,19]
#s = bisect_left(a,4)
#s=2
a,b,c,d,e,f=map(int,input().split())
wa=set()
a*=100
b*=100
for i in range((f+a-1)//a+1):
    for j in range((f+b-1)//b+1):
        if 1<=i*a+j*b<=f:
            wa.add(i*a+j*b)
su=set()
e=100*e/(100+e)
x=int(f*e//100)
for i in range((x+c-1)//c+1):
    for j in range((x+d-1)//d+1):
        if i*c+j*d<=x:
            su.add(i*c+j*d)
su=sorted(list(su))
# print(wa)
# print(su)
ans=0
x,y=0,0
e+=0.001
for i in wa:
    # print(i,su[bisect_left(su,f-i)-1],su[bisect_left(su,e*i/(100-e))-1])
    p=min(bisect_left(su,f-i),bisect_left(su,e*i/(100-e)))
    if p>0:
        if ans<=su[p-1]/(i+su[p-1]):
            ans=su[p-1]/(i+su[p-1])
            x,y=i,su[p-1]
print(max(x+y,a),y)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left 
#bisect_left(a,x):a[i]>=xとなるような最小のi.
#昇順ソートされたリストaに昇順を崩さずxを挿入できる位置s(0-index)を返す.
#a=[1,3,5,7,9,11,13,15,17,19]
#s = bisect_left(a,4)
#s=2
a,b,c,d,e,f=map(int,input().split())
wa=set()
a*=100
b*=100
for i in range((f+a-1)//a+1):
    for j in range((f+b-1)//b+1):
        if 1<=i*a+j*b<=f:
            wa.add(i*a+j*b)
su=set()
e=100*e/(100+e)
x=int(f*e//100)
for i in range((x+c-1)//c+1):
    for j in range((x+d-1)//d+1):
        if i*c+j*d<=x:
            su.add(i*c+j*d)
su=sorted(list(su))
# print(wa)
# print(su)
ans=0
x,y=0,0
e+=0.001
for i in wa:
    # print(i,su[bisect_left(su,f-i)-1],su[bisect_left(su,e*i/(100-e))-1])
    p=min(bisect_left(su,f-i),bisect_left(su,e*i/(100-e)))
    if p>0:
        if ans<=su[p-1]/(i+su[p-1]):
            ans=su[p-1]/(i+su[p-1])
            x,y=i,su[p-1]
print(max(x+y,min(wa)),y)