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 = list(map(int, input().split()))
maxdensity=0;
maxtotal=0;
maxsugar=0;

listwater = list()
for nA in range(30):
	for nB in range(15):
		water = 100*(nA*A+nB*B)
		if water == 0:
			continue
		if water <= F and (not water in listwater):
			listwater.append(water)

listsugar = list()
for nC in range(3000):
	for nD in range(1500):
		sugar = (nC*C+nD*D)
		if sugar <= F/2 and (not sugar in listsugar):
			listsugar.append(sugar)

listsugar.sort()
listwater.sort()

for i in range(len(listsugar)):
	for j in range(len(listwater)):
		total = listsugar[i] + listwater[j]
		sugar = listsugar[i]
		if total == 0:
			continue
		if total <= F and (sugar*100 <= E*(total-sugar)):
			if maxdensity*total < sugar:
				maxdensity = float(sugar)/float(total)
				maxtotal = total
				maxsugar = sugar
		
					
						
print(maxtotal,end=" ")
print(maxsugar)

Submission status: Wrong Answer

Solution code:
#python3

#cups for water, spoons for sugar
cup1, cup2, spoon1, spoon2, max_density, max_volume = (int(x) for x in input().split())

possible_water_volumes = set()

for cups1_nr in range(0, 30):
    for cups2_nr in range(0, 30):
        curr_water_volume = cups1_nr * cup1 + cups2_nr * cup2
        if curr_water_volume <= max_volume and curr_water_volume != 0:
            possible_water_volumes.add(curr_water_volume)

global_optimal_sugar = 0
global_optimal_water = cup1            
for water_volume in possible_water_volumes:
    curr_optimal_sugar = water_volume * max_density
    for spoons1_nr in range(0, 100):
        curr_sugar = spoon1 * spoons1_nr
        spoons2_nr = ((curr_optimal_sugar - curr_sugar) // spoon2)
        curr_sugar += spoon2 * spoons2_nr
        if curr_sugar + water_volume * 100 > max_volume:
            continue
        elif curr_sugar > curr_optimal_sugar:
            continue
        elif (curr_sugar / water_volume) > (global_optimal_sugar / global_optimal_water):
            # print(curr_sugar, water_volume)
            global_optimal_sugar = curr_sugar
            global_optimal_water = water_volume
            
sugar_water_volume = global_optimal_water * 100 + global_optimal_sugar
print(sugar_water_volume, global_optimal_sugar)

Submission status: Wrong Answer

Solution code:
#python3

#cups for water, spoons for sugar
cup1, cup2, spoon1, spoon2, max_density, max_volume = (int(x) for x in input().split())

possible_water_volumes = set()

for cups1_nr in range(0, 30):
    for cups2_nr in range(0, 30):
        curr_water_volume = cups1_nr * cup1 + cups2_nr * cup2
        if curr_water_volume <= max_volume and curr_water_volume != 0:
            possible_water_volumes.add(curr_water_volume)

global_optimal_sugar = 0
global_optimal_water = cup1            
for water_volume in possible_water_volumes:
    curr_optimal_sugar = water_volume * max_density
    for spoons1_nr in range(0, 100):
        curr_sugar = spoon1 * spoons1_nr
        spoons2_nr = (curr_optimal_sugar - curr_sugar) // spoon2
        curr_sugar += spoon2 * spoons2_nr
        if curr_sugar + water_volume * 100 > max_volume:
            continue
        elif curr_sugar > curr_optimal_sugar:
            continue
        elif (curr_sugar / water_volume) > (global_optimal_sugar / global_optimal_water):
            # print(curr_sugar, water_volume)
            global_optimal_sugar = curr_sugar
            global_optimal_water = water_volume
            
sugar_water_volume = global_optimal_water * 100 + global_optimal_sugar
print(sugar_water_volume, global_optimal_sugar)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

class water_node():
    def is_meltable(self):
        if self.sugar <= self.water * self.meltable/100:
            return True
        return False
    def __init__(self, water, sugar, meltable):
        self.water = water
        self.sugar = sugar
        self.mass = water + sugar
        self.meltable = meltable
        self.is_all_melt = self.is_meltable()
        if self.sugar + self.water > 0:
            self.concentration = self.sugar * 100.0 /float(self.sugar + self.water)
        else:
            self.concentration = 0.0


    def __eq__(self,other):
        return (self.water  == other.water) and (self.sugar  == other.sugar)

    def __hash__(self):

        return hash (self.water + self.sugar* 10000)


def BFS(A, B, C, D, E, F):
    n = water_node(0, 0, E)
    done_set = set([n])
    node_list = deque([n])
    max_concentration_node = n
    while len(node_list) > 0:
        n = node_list.popleft()
        #ope1
        new_node_list = []
        new_node_list.append(water_node(n.water + A * 100, n.sugar, E))
        new_node_list.append(water_node(n.water + B * 100, n.sugar, E))
        new_node_list.append(water_node(n.water, n.sugar + C, E))
        new_node_list.append(water_node(n.water, n.sugar + D, E))
        for new_node in new_node_list:
            if new_node.mass <= F:
                if new_node not in done_set:
                    done_set.add(new_node)
                    node_list.append(new_node)
                    if new_node.is_all_melt == True and new_node.concentration > max_concentration_node.concentration:
                        max_concentration_node = new_node
    return max_concentration_node


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C, D, E, F] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2]), int(input_raw[3]), int(input_raw[4]), int(input_raw[5])]
    max_c = BFS(A, B, C, D, E, F)
    print int(max_c.mass), int(max_c.sugar)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#python3

#cups for water, spoons for sugar
cup1, cup2, spoon1, spoon2, max_density, max_volume = (int(x) for x in input().split())

possible_water_volumes = set()

for cups1_nr in range(0, 30):
    for cups2_nr in range(0, 30):
        curr_water_volume = cups1_nr * cup1 + cups2_nr * cup2
        if curr_water_volume <= max_volume and curr_water_volume != 0:
            possible_water_volumes.add(curr_water_volume)

global_optimal_sugar = 0
global_optimal_water = cup1            
for water_volume in possible_water_volumes:
    curr_optimal_sugar = water_volume * max_density
    for spoons1_nr in range(0, 100):
        curr_sugar = spoon1 * spoons1_nr
        spoons2_nr = (curr_optimal_sugar - curr_sugar) // spoon2
        curr_sugar += spoon2 * spoons2_nr
        if curr_sugar + water_volume * 100 >= max_volume:
            continue
        elif curr_sugar > curr_optimal_sugar:
            continue
        elif (curr_sugar / water_volume) > (global_optimal_sugar / global_optimal_water):
            # print(curr_sugar, water_volume)
            global_optimal_sugar = curr_sugar
            global_optimal_water = water_volume
            
sugar_water_volume = global_optimal_water * 100 + global_optimal_sugar
print(sugar_water_volume, global_optimal_sugar)

Submission status: Wrong Answer

Solution code:
import itertools

def solve():
    a, b, c, d, e, f = map(int, input().split())
    water_pair = []
    a_list = [a * i * 100 for i in range(f//(a * 100) + 1)]
    b_list = [b * i * 100 for i in range(f//(b * 100) + 1)]
    for elem in list(itertools.permutations(a_list + b_list, 2)):
        water_pair.append(elem[0] + elem[1])
    
    solt_max = int(f * ((100 * e) / (100 + e) / 100))
    water_pair = [i for i in set(water_pair) if f > i > 0]
    solt_pair = []
    c_list = [c * i for i in range(solt_max//c + 1)]
    d_list = [d * i for i in range(solt_max//b + 1)]
    for elem in list(itertools.permutations(c_list + d_list, 2)):
        solt_pair.append(elem[0] + elem[1])
    solt_pair = [i for i in set(solt_pair) if solt_max >= i]
    
    water_pair.sort()
    solt_pair.sort()
    max_pair = 0
    ans = [0, 0]
    for water in water_pair:
        limit_solt = e * (water // 100)
        for solt in solt_pair:
            if solt > limit_solt:
                break
            if water + solt > f:
                break
            if (100 * solt) / (water + solt) > max_pair:
                max_pair = (100 * solt) / (water + solt)
                ans = [water + solt, solt]
    print(ans[0], ans[1])
    

if __name__=="__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

A,B,C,D,E,F = map(int, input().split())
A *= 100
B *= 100
E = round(E/(100+E), 18)

# binary search
def check(i, total, sugar):
	exp = (sugar + D*i) / (total + D*i)
	return total + D*i <= F and round(exp, 15) <= E
	

def binarySearch(small, big, total, sugar):
	mid = (big + small) // 2
	if big - small <= 1:
		if check(big, total, sugar): return big
		else:          return small
	else:
		if check(mid, total, sugar):
			return binarySearch(mid, big, total, sugar)
		else:
			return binarySearch(small, mid, total, sugar)

noudo = 0
ans = (0, 0)
for a in range(31):
	for b in range(31):
		for c in range(3001):
			water = a*A + b*B
			sugar = c * C
			total = water + sugar
			if not (a, b) == (0, 0):
				if total <= F and round(sugar / total, 15) <= E:
					d = binarySearch(0, 3000, total, sugar)
					tmp = (sugar + D*d) / (total + D*d)
					if round(tmp, 15) > noudo:
						noudo = round(tmp, 15)
						ans = (total+D*d, sugar+D*d)

if ans[0] == 0:
	print(A, 0)
else:
	print(ans[0], ans[1])

Submission status: Wrong Answer

Solution code:
#python3

#cups for water, spoons for sugar
cup1, cup2, spoon1, spoon2, max_density, max_volume = (int(x) for x in input().split())

possible_water_volumes = set()

for cups1_nr in range(0, 30):
    for cups2_nr in range(0, 30):
        curr_water_volume = cups1_nr * cup1 + cups2_nr * cup2
        if curr_water_volume <= max_volume and curr_water_volume != 0:
            possible_water_volumes.add(curr_water_volume)

global_optimal_sugar = 0
global_optimal_water = cup1            
for water_volume in possible_water_volumes:
    curr_optimal_sugar = water_volume * max_density
    for spoons1_nr in range(0, 100):
        curr_sugar = spoon1 * spoons1_nr
        spoons2_nr = (curr_optimal_sugar - curr_sugar) // spoon2
        curr_sugar += spoon2 * spoons2_nr
        if curr_sugar + water_volume * 100 >= max_volume:
            continue
        elif curr_sugar > curr_optimal_sugar:
            continue
        elif (curr_sugar / water_volume) > (global_optimal_sugar / global_optimal_water):
            # print(curr_sugar, water_volume_
            global_optimal_sugar = curr_sugar
            global_optimal_water = water_volume
            
sugar_water_volume = global_optimal_water * 100 + global_optimal_sugar
print(sugar_water_volume, global_optimal_sugar)

Submission status: Wrong Answer

Solution code:

def spaceinput():
    return list(map(int,input().split(" ")))

a,b,c,d,e,f=spaceinput()


smax=0
wmax=0
maxnoudo=0

for na in range(int(f/(100*a))+1):
    for nb in range(int(f/(100*b))+1):
        for nc in range(int(f/c)+2):
            for nd in range(int(f/d)+2):
                W=na*100*a+nb*100*b
                S=nc*c+nd*d


                if W+S>f:
                    break

                if W+S==0:
                    continue

                noudo=S/(W+S)
                #print(noudo,S,W,f,e)
                #print("aaa")
                if noudo>e/(100+e):
                    break

                #print(na,nb,nc,nd)
                if maxnoudo<noudo:
                    maxnoudo=noudo
                    smax=S
                    wmax=W
                    #input()


print(smax+wmax,smax)

Submission status: Wrong Answer

Solution code:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

A,B,C,D,E,F = map(int, input().split())
A *= 100
B *= 100
E = round(E/(100+E), 10)

# binary search
def check(i, total, sugar):
	exp = (sugar + D*i) / (total + D*i)
	return total + D*i <= F and round(exp, 8) <= E
	

def binarySearch(small, big, total, sugar):
	mid = (big + small) // 2
	if big - small <= 1:
		if check(big, total, sugar): return big
		else:          return small
	else:
		if check(mid, total, sugar):
			return binarySearch(mid, big, total, sugar)
		else:
			return binarySearch(small, mid, total, sugar)

noudo = 0
ans = (0, 0)
for a in range(31):
	for b in range(31):
		for c in range(3001):
			water = a*A + b*B
			sugar = c * C
			total = water + sugar
			if not (a, b) == (0, 0):
				if total <= F and round(sugar / total, 8) <= E:
					d = binarySearch(0, 3000, total, sugar)
					tmp = (sugar + D*d) / (total + D*d)
					if round(tmp, 8) > noudo:
						noudo = round(tmp, 8)
						ans = (total+D*d, sugar+D*d)

if ans[0] == 0:
	print(A, 0)
else:
	print(ans[0], ans[1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B, C, D, E, F = tuple(map(int, input().split()))
A, B = 100*A, 100*B
waters = set([a+b for b in range(0, F+1, B) for a in range(0, F+1, A) if a+b <= F])

res_water = 0
res_sugar = 0
max_ratio = 0

for w in sorted(waters):
    sugars = [c+d for c in range(0, int(w//100)*E+1, C)
                         for d in range(0, int(w//100)*E+1, D) 
                             if (c+d+w <= F) and (c+d <= int(w/100)*E)]
    sugar = max(sugars)
    #print(sugars)
    if w+sugar==0:
        continue
    if 100*sugar / (w+sugar) > max_ratio:
        max_ratio = 100*sugar / (w+sugar)
        res_water = w
        res_sugar = sugar
print("{} {}".format(res_water+res_sugar, res_sugar))

Submission status: Wrong Answer

Solution code:

def spaceinput():
    return list(map(int,input().split(" ")))

a,b,c,d,e,f=spaceinput()


smax=0
wmax=0
maxnoudo=0

for na in range(int(f/(100*a))+1):
    for nb in range(int(f/(100*b))+1):
        for nc in range(int(f/c)+2):
            for nd in range(int(f/d)+2):
                W=na*100*a+nb*100*b
                S=nc*c+nd*d
                if W==0:
                    continue

                if W+S>f:
                    continue

                noudo=S/(W+S)
                #print(noudo,S,W,f,e)
                #print("aaa")
                if noudo>e/(100+e):
                    continue

                #print(na,nb,nc,nd)
                if maxnoudo<noudo:
                    maxnoudo=noudo
                    smax=S
                    wmax=W
                    #input()


print(smax+wmax,smax)

Submission status: Wrong Answer

Solution code:
def spaceinput():
    return list(map(int,input().split(" ")))

a,b,c,d,e,f=spaceinput()


smax=0
wmax=0
maxnoudo=0

for na in range(int(f/(100*a))+2):
    for nb in range(int(f/(100*b))+2):
        for nc in range(int(f/c)+2):
            for nd in range(int(f/d)+2):
                W=na*100*a+nb*100*b
                S=nc*c+nd*d
                if W*S==0:
                    continue

                noudo=S/(W+S)
                if W+S>f:
                    break
                #print(noudo,S,W,f,e)
                #print("aaa")
                if noudo>e/(100+e):
                    continue

                #print(na,nb,nc,nd)
                if maxnoudo<noudo:
                    maxnoudo=noudo
                    smax=S
                    wmax=W
                    #input()


print(smax+wmax,smax)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B, C, D, E, F = tuple(map(int, input().split()))
A, B = 100*A, 100*B
waters = set([a+b for b in range(0, F+1, B) for a in range(0, F+1, A) if a+b <= F])

res_water = 0
res_sugar = 0
max_ratio = 0

for w in sorted(waters):
    sugars = [c+d for c in range(0, int(w/100)*E+1, C)
                         for d in range(0, int(w/100)*E+1, D) 
                             if (c+d+w <= F) and (c+d <=int(w/100)*E)]
    sugar = max(sugars)
    #print(sugars)
    if w+sugar==0:
        continue
    if 100*sugar / (w+sugar) > max_ratio:
        max_ratio = 100*sugar / (w+sugar)
        res_water = w
        res_sugar = sugar
print("{} {}".format(res_water+res_sugar, res_sugar))

Submission status: Wrong Answer

Solution code:

def spaceinput():
    return list(map(int,input().split(" ")))

a,b,c,d,e,f=spaceinput()


smax=0
wmax=0
maxnoudo=0

for na in range(int(f/(100*a))+2):
    for nb in range(int(f/(100*b))+2):
        for nc in range(int(f/c)+2):
            for nd in range(int(f/d)+2):
                W=na*100*a+nb*100*b
                S=nc*c+nd*d
                if W*S==0:
                    continue

                noudo=S/(W+S)
                if W+S>f:
                    break
                #print(noudo,S,W,f,e)
                #print("aaa")
                #if noudo>e/(100+e):
                #    break

                #print(na,nb,nc,nd)
                if maxnoudo<noudo:
                    maxnoudo=noudo
                    smax=S
                    wmax=W
                    #input()


print(smax+wmax,smax)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e,f=map(int,input().split())
ans1,ans2=0,0
water1,water2,sugar1,sugar2=0,0,0,0
while ans1 <= f:
	water1+=a*100
	water2+=b*100
	sugar1+=c*(e//c)
	sugar2+=d*(e//d)
	sugar=max(sugar1,sugar2)
	ans1+=(water1+sugar*a)
	ans2+=(water2+sugar*b)
	if ans1 <= f:
		print(ans1,ans1-water1)
		break
	elif ans2 <= f:
		print(ans2,ans2-water2)
		break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B, C, D, E, F = tuple(map(int, input().split()))
A, B = 100*A, 100*B
waters = set([a+b for b in range(0, F+1, B) for a in range(b, F-b+1, A)])

res_water = 0
res_sugar = 0
max_ratio = 0

for w in sorted(waters):
    sugars = [c+d for c in range(0, int(w/100)*E+1, C)
                         for d in range(0, int(w/100)*E+1, D) 
                             if (c+d+w <= F) and (c+d <=int(w/100)*E)]
    sugar = max(sugars)
    #print(sugars)
    if w+sugar==0:
        continue
    if 100*sugar / (w+sugar) > max_ratio:
        max_ratio = 100*sugar / (w+sugar)
        res_water = w
        res_sugar = sugar
print("{} {}".format(res_water+res_sugar, res_sugar))

Submission status: Wrong Answer

Solution code:

def spaceinput():
    return list(map(int,input().split(" ")))

a,b,c,d,e,f=spaceinput()


smax=wmax=0
maxnoudo=0

for na in range(int(f/(100*a))+1):
    for nb in range(int(f/(100*b))+1):
        for nc in range(int(f/c)+2):
            for nd in range(int(f/d)+2):
                W=na*100*a+nb*100*b
                S=nc*c+nd*d
                if W*S==0:
                    continue

                noudo=S/(W+S)
                if W+S>f:
                    break
                #print(noudo,S,W,f,e)
                #print("aaa")
                if noudo>e/(100+e):
                    break

                #print(na,nb,nc,nd)
                if maxnoudo<noudo:
                    maxnoudo=noudo
                    smax=S
                    wmax=W
                    #input()


print(smax+wmax,smax)

Submission status: Wrong Answer

Solution code:
def get_set(_max, a, b):
    ans = set()
    g = _max // a
    for h in range(g + 1):
        i = a * h
        ans.add(i)
        j = _max - i
        k = j // b
        for l in range(k + 1):
            m = b * l
            ans.add(i + m)
    ans.remove(0)
    return ans


a, b, c, d, e, f = map(int, input().split())
ab = get_set(f, a * 100, b * 100)
max_l, max_s, max_r = 0, 0, 0
for n in ab:
    o = min(f - n, n * e // 100)
    tmp_max = max(get_set(o, c, d), default=0)
    tmp_rate = tmp_max / (n + tmp_max)
    if tmp_rate > max_r:
        max_l = n
        max_s = tmp_max
        max_r = tmp_rate

print(max_l + max_s, max_s)

Submission status: Wrong Answer

Solution code:

def spaceinput():
    return list(map(int,input().split(" ")))

a,b,c,d,e,f=spaceinput()



smax=wmax=0
maxnoudo=0

for na in range(int(f/(100*a))+1):
    for nb in range(int(f/(100*b))+1):
        for nc in range(int(e*f/(100*c))+1):
            for nd in range(int(e*f/(100*d))+1):
                W=na*100*a+nb*100*b
                S=nc*c+nd*d
                if W*S==0:
                    continue

                noudo=S/(W+S)
                if W+S>f:
                    break
                #print(noudo,S,W,f,e)
                #print("aaa")
                if noudo>e/(100+e):
                    break

                #print(na,nb,nc,nd)
                if maxnoudo<noudo:
                    maxnoudo=noudo
                    smax=S
                    wmax=W
                    #input()


print(smax+wmax,smax)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B, C, D, E, F = tuple(map(int, input().split()))
A, B = 100*A, 100*B
waters = set([a+b for b in range(0, F+1, B) for a in range(b, F-b+1, A)])

res_water = 0
res_sugar = 0
max_ratio = 0

for w in sorted(waters):
    sugar = max([c+d for c in range(0, int(w/100)*E+1, C)
                         for d in range(c, int(w/100)*E-c+1, D) if (c+d+w <= F)])
    if w+sugar==0:
        continue
    if 100*sugar / (w+sugar) > max_ratio:
        max_ratio = 100*sugar / (w+sugar)
        res_water = w
        res_sugar = sugar
print("{} {}".format(res_water+res_sugar, res_sugar))

Submission status: Wrong Answer

Solution code:
from sys import stdin 
a,b,c,d,e,f = map(int,stdin.readline().split())
fir = [0] * (f+1)
sec = [0] * (f+1)
# first check what water and sugar amounts are possible
fir[0] = sec[0] = 1 
for i in xrange(f+1):
    nex = i + a*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i + c 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
    nex = i + b*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i +  d 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
valid = []
for i in xrange(1,f+1):
    for j in xrange(1,f+1):
        # taking i water and j sugar
        if fir[i] and sec[j]:
            if i +  j<=f:
                if e*i >= 100*j:
                    valid.append((i,j))
num = 0
den = 1*100
for y,x in valid:
    if x*den > y*num:
        num = x
        den = y
print num+den,num

Submission status: Wrong Answer

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

water_dp = [True] + [False for _ in range(100)]
suger_dp = [True] + [False for _ in range(f + 100)]

for i in range(0, 31):
    water_dp[i+a] = water_dp[i+a] or water_dp[i]
    water_dp[i+b] = water_dp[i+b] or water_dp[i]

for i in range(0, f+1):
    suger_dp[i+c] = suger_dp[i+c] or suger_dp[i]
    suger_dp[i+d] = suger_dp[i+d] or suger_dp[i]

ans = (0, 0, 0)

for i in range(1, 31):
    if not water_dp[i]:
        continue
    suger = 0
    for j in range(0, f):
        if suger_dp[j] and i*100 + j <= f and j <= e * i:
            suger = j
    if suger * 100 / (i*100 + suger) > ans[2]:
        ans = (i, suger, suger * 100 / (i*100 + suger))

print(ans[0]*100 + ans[1], ans[1])

Submission status: Wrong Answer

Solution code:
from sys import stdin 
a,b,c,d,e,f = map(int,stdin.readline().split())
fir = [0] * (f+1)
sec = [0] * (f+1)
# first check what water and sugar amounts are possible
fir[0] = sec[0] = 1 
for i in xrange(f+1):
    nex = i + a*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i + c 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
    nex = i + b*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i +  d 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
valid = []
for i in xrange(1,f+1):
    for j in xrange(1,f+1):
        # taking i water and j sugar
        if fir[i] and sec[j]:
            if i +  j<=f:
                if e*i >= 100*j:
                    valid.append((i,j))
num = 0
den = 1
for y,x in valid:
    if x*den > y*num:
        num = x
        den = y
print num+den,num

Submission status: Wrong Answer

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


from itertools import product
water = set()

for i,j in product(range(f//(a*100)+2),range(f//(100*b)+2)):
  n = a*i+b*j
  if n <= f:
    water.add(n)

water = sorted(water)

salt = set()

for i,j in product(range(f//c+2),range(f//d+2)):
  n = c*i+d*j
  if n <= f:
    salt.add(n)

salt = sorted(salt)

from bisect import bisect_left



bs,bw = 0,1
for s in salt:
  w = s/e
  i = bisect_left(water,w)
  if i >= len(water):
    break
  w = water[i]
  if 100*w + s > f:
    break
  if bs*w < bw*s:
    bs,bw = s,w

print(bs+100*bw,bs)

Submission status: Wrong Answer

Solution code:
from sys import stdin 
a,b,c,d,e,f = map(int,stdin.readline().split())
fir = [0] * (f+1)
sec = [0] * (f+1)
# first check what water and sugar amounts are possible
fir[0] = sec[0] = 1 
for i in xrange(f+1):
    nex = i + a*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i + c 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
    nex = i + b*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i +  d 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
valid = []
for i in xrange(1,f+1):
    for j in xrange(1,f+1):
        # taking i water and j sugar
        if fir[i] and sec[j]:
            if i +  j<=f:
                if e*i >= 100*j:
                    valid.append((i,j))
num = 0
den = 100
for y,x in valid:
    if x*den > y*num:
        num = x
        den = y
print num+den,num

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, raw_input().split())
e1 = e / (100.0 + e)
mx = 0.0
ans1 = 0.0
ans2 = 0.0
for i in xrange(f / (100 * a) + 1):
    for j in xrange(f / (100 * b) + 1):
        if i == 0 and j == 0 : continue
        for k in xrange(f / c + 1):
            for l in xrange(f / d + 1):
                if 100 * a * i + 100 * b * j + c * k + d * l > f: continue
                tmp = float(c * k + d * l) / float(c * k + d * l + 100 * a * i + 100 * b * j);
                if tmp > e1: continue
                if mx < tmp:
                    mx = tmp
                    ans1 = 100 * a * i + 100 * b * j + c * k + d * l
                    ans2 = c * k + d * l
print ans1, ans2

Submission status: Wrong Answer

Solution code:
from sys import stdin 
a,b,c,d,e,f = map(int,stdin.readline().split())
fir = [0] * (f+1)
sec = [0] * (f+1)
# first check what water and sugar amounts are possible
fir[0] = sec[0] = 1 
for i in xrange(f+1):
    nex = i + a*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i + c 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
    nex = i + b*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i +  d 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
valid = [(1,0)]
for i in xrange(1,f+1):
    for j in xrange(1,f+1):
        # taking i water and j sugar
        if fir[i] and sec[j]:
            if i +  j<=f:
                if e*i >= 100*j:
                    valid.append((i,j))
num = 0
den = 1
for y,x in valid:
    if x*den > y*num:
        num = x
        den = y
print num+den,num

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import heapq
import math

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

# print valid waters
n1, n2 = [F // (a * 100) for a in [A, B]]
ws = []
for i in range(n1+1):
    for j in range(n2+1):
        if i == 0 and j == 0: continue
        a1, a2 = i, j
        w = (a1 * A + a2 * B) * 100
        if w <= F:
            ws.append(w)
        else:
            break
ws = sorted(ws)
ss = []
for w in ws:
    remain = F - w
    max_sugar = w / 100.0 * E
    max_sugar = min(remain, max_sugar)

    x = 0
    max_tmp = -1
    while x * C < max_sugar:
        y = (max_sugar - (x * C) ) // D
        s = x*C + y*D
        if s > max_tmp:
            max_tmp = s
        x += 1
    ss.append([w, max_tmp])
max_tmp = None
for i, a in enumerate(ss):
    noudo = 1.0 * a[1] / (a[0] + a[1])
    if max_tmp is None or max_tmp[2] < noudo:
        max_tmp = [a[0], a[1], noudo]
print(max_tmp[0]+max_tmp[1], max_tmp[1])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)
a, b, c, d, e, f = map(int, input().split())
def dfs(g, a, b, can, base=100):
    if not base*g <= f:
        return
    if g in can:
        return
    can[g] = 1
    dfs(g + a, a, b, can)
    dfs(g + b, a, b, can)
can1 = {}
dfs(0, a, b, can1)
can2 = {}
dfs(0, c, d, can2, 1)

ans = (0, 0, 0)
for g in can1:
    if g == 0:
        continue
    rest = f - 100*g
    result = max([0]+[h for h in can2 if h <= min(rest, e*g)])
    ans = max(ans, (result / (100*g + result), 100*g, result))
print(ans[1]+ans[2], ans[2])