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:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b, c, d, e, f = LI()
    lis = []
    for i in range(3001):
        for k in range(3001):
            lis.append(c * i + d * k)
    lis.sort()
    ans = [0, 0]
    for i in range(31):
        for k in range(31):
            water = (a * i + b * k)
            if water * e <= f - water * 100:
                aa = bisect_right(lis, water * e) - 1
                if aa == -1:
                    continue
                aa = lis[aa]
                if ans[0] == 0:
                    ans = [water * 100 + aa, aa]
                else:
                    if ans[1] / ans[0] < aa / (water * 100 + aa):
                        ans = [water * 100 + aa, aa]
    print(*ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b, c, d, e, f = LI()
    lis = []
    for i in range(3001):
        for k in range(3001):
            lis.append(c * i + d * k)
    lis.sort()
    ans = [0, 0]
    for i in range(31):
        for k in range(31):
            water = (a * i + b * k)
            if water * e <= f - water * 100:
                if lis[0] > water * e:
                    continue
                aa = bisect_right(lis, water * e) - 1
                aa = lis[aa]
                if ans[0] == 0:
                    ans = [water * 100 + aa, aa]
                else:
                    if ans[1] / ans[0] < aa / (water * 100 + aa):
                        ans = [water * 100 + aa, aa]
    print(*ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b, c, d, e, f = LI()
    lis = []
    for i in range(3001):
        for k in range(3001):
            lis.append(c * i + d * k)
    lis.sort()
    ans = [0, 0]
    for i in range(31):
        for k in range(31):
            water = (a * i + b * k)
            if water * e < f - water * 100:
                if lis[0] > water * e:
                    continue
                aa = bisect_right(lis, water * e) - 1
                aa = lis[aa]
                if ans[0] == 0:
                    ans = [water * 100 + aa, aa]
                else:
                    if ans[1] / ans[0] < aa / (water * 100 + aa):
                        ans = [water * 100 + aa, aa]
    print(*ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b, c, d, e, f = LI()
    lis = []
    for i in range(3001):
        for k in range(3001):
            lis.append(c * i + d * k)
    lis.sort()
    ans = [0, 0]
    for i in range(31):
        for k in range(31):
            water = (a * i + b * k)
            if water * e < f - water * 100:
                if lis[0] >= water * e:
                    continue
                aa = bisect_right(lis, water * e)-1
                aa = lis[aa]
                if ans[0] == 0:
                    ans = [water * 100 + aa, aa]
                else:
                    if ans[1] / ans[0] < aa / (water * 100 + aa):
                        ans = [water * 100 + aa, aa]
    print(*ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b, c, d, e, f = LI()
    lis = []
    for i in range(3001):
        for k in range(3001):
            lis.append(c * i + d * k)
    lis.sort()
    ans = [0, 0]
    for i in range(31):
        for k in range(31):
            water = (a * i + b * k)
            if water * e < f - water * 100:
                if lis[0] >= water * e:
                    continue
                aa = bisect_left(lis, water * e) - 1
                aa = lis[aa]
                if ans[0] == 0:
                    ans = [water * 100 + aa, aa]
                else:
                    if ans[1] / ans[0] < aa / (water * 100 + aa):
                        ans = [water * 100 + aa, aa]
    print(*ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# ABC074 C - Sugar Water
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a,b,c,d,e,f = nm()
L =[]
for aa in range(0,31):
    for bb in range(0,31):
        for cc in range(0,31):
            for dd in range(0,31):
                if 100*a<=100*a*aa+100*b*bb+c*cc+d*dd<=f:
                    L.append((aa,bb,cc,dd))

max_w = 0.0
idx = 10*7
for i,l in enumerate(L):
    # water = 100*a*l[0]+100*b*l[1]+c*l[2]+d*l[3]
    water = 100*a*l[0]+100*b*l[1]+c*l[2]+d*l[3]
    sugar = c*l[2]+d*l[3]
    if (100+e)*100*sugar<=(100*e)*water:
        # if water!=0 and (l[0]>0 or l[1]>0):
        if l[0]>0 or l[1]>0:
            t = (sugar/water)*100
            if t>=max_w:
                max_w=t
                idx = i

for i,l in enumerate(L):
    if i==idx:
        water = 100*a*l[0]+100*b*l[1]+c*l[2]+d*l[3]
        sugar = c*l[2]+d*l[3]
        print(water,sugar)
        exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C, D, E, F):
    ans = 0
    w = set()
    for i in range(F//A + 1):
        for j in range(F//B + 1):
            m = 100*(i*A + j*B)
            if m < F:
                w.add(m)
    mw = max(w)


    ms = (mw // 100) * E
    s = set()
    for i in range(ms+1):
        for j in range(ms+1):
            s.add(i*C + j*D)
    W = sorted(w)
    S = sorted(s)

    ans = (0, A*100, 0)
    for w in W:
        if w == 0:
            continue
        ts = w // 100 * E
        si = bisect.bisect_left(S, ts)
        if S[si] == ts:
            s = ts
        else:
            if si == 0:
                continue
            s = S[si-1]
        if s + w <= F and  s / w > ans[0]:
            ans = (s/w, w + s, s)
    return ' '.join(map(str, ans[1:]))


def main():
    A, B, C, D, E, F = read_int_n()
    print(slv(A, B, C, D, E, F))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C, D, E, F):
    ans = 0
    w = set()
    for i in range(F//A + 1):
        for j in range(F//B + 1):
            m = 100*(i*A + j*B)
            if m < F:
                w.add(m)
    mw = max(w)


    ms = (mw // 100) * E
    s = set()
    for i in range(ms+1):
        for j in range(ms+1):
            s.add(i*C + j*D)
    W = sorted(w)
    S = sorted(s)

    ans = (0, None, None)
    for w in W:
        if w == 0:
            continue
        ts = w // 100 * E
        si = bisect.bisect_left(S, ts)
        if S[si] == ts:
            s = ts
        else:
            if si == 0:
                continue
            s = S[si-1]
        if s + w <= F and  s / w > ans[0]:
            ans = (s/w, w + s, s)
    return ' '.join(map(str, ans[1:]))


def main():
    A, B, C, D, E, F = read_int_n()
    print(slv(A, B, C, D, E, F))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C, D, E, F):
    ans = 0
    w = set()
    for i in range(F//A + 1):
        for j in range(F//B + 1):
            m = 100*(i*A + j*B)
            if m < F:
                w.add(m)
    mw = max(w)


    ms = (mw // 100) * E
    s = set()
    for i in range(ms+1):
        for j in range(ms+1):
            s.add(i*C + j*D)
    W = sorted(w)
    S = sorted(s)

    ans = (0, None, None)
    for w in W:
        if w == 0:
            continue
        ts = w // 100 * E
        si = bisect.bisect_left(S, ts)
        if S[si] == ts:
            s = ts
        else:
            s = S[si-1]
        if s + w <= F and  s / w > ans[0]:
            ans = (s/w, w + s, s)
    return ' '.join(map(str, ans[1:]))


def main():
    A, B, C, D, E, F = read_int_n()
    print(slv(A, B, C, D, E, F))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = [0, 0]
max_conc = 0
for a in range(F // 100 + 1):
    left = F - 100 * a * A
    for b in range(left // 100 + 1):
        w = 100 * a * A + 100 * b * B

        s_max = min(F - w, w * E // 100)
        if s_max >= 0:
            for c in range(s_max // C + 1):
                d = (s_max - c * C) // D

                if d >= 0:
                    # suger
                    s = c * C + d * D
                    if s + w > 0:
                        conc = s / (s + w)
                        if conc > max_conc:
                            ans = [s, w]
                            max_conc = conc


print(str(ans[0] + ans[1]) + ' ' + str(ans[0]))

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

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

def main():
    ans_sw=a
    ans_s=0
    for an in range(f+1):
        if a*an*100>f:break
        for bn in range(f+1):
            w=an*a+bn*b
            if w*100>f:break
            lim=min(w*e,f-w*100)
            for cn in range(f+1):
                dn=(lim-c*cn)//d
                if dn<0:break
                s=c*cn+d*dn
                if s*ans_sw>ans_s*(s+100*w):
                    ans_sw=s+100*w
                    ans_s=s
    print(ans_sw,ans_s)

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

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

def main():
    ans_sw=a
    ans_s=0
    for an in range(f):
        if a*an*100>f:break
        for bn in range(f):
            w=an*a+bn*b
            if w*100>f:break
            lim=min(w*e,f-w*100)
            for cn in range(f):
                dn=(lim-c*cn)//d
                if dn<0:break
                s=c*cn+d*dn
                if s*ans_sw>ans_s*(s+100*w):
                    ans_sw=s+100*w
                    ans_s=s
    print(ans_sw,ans_s)

main()

Submission status: Wrong Answer

Solution code:
#何でこのプログラムで通らないか分からん
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a, b, c, d, e, f = MI()
    max_sw=a
    max_s=0
    for an in range(f // (100 * a) + 1):
        for bn in range((f - 100 * a * an) // (100 * b) + 1):
            w = a * an + b * bn
            if w == 0: continue
            if 100 * w > f: break
            for cn in range(f):
                dn = (min(w*e,f-100*w)-c*cn)//d
                if dn < 0: break
                #print(an,bn,cn,dn)
                s = c * cn + d * dn
                if s*max_sw>max_s*(s+w*100):
                    max_sw=s+100*w
                    max_s=s
    print(max_sw,max_s)

main()

Submission status: Wrong Answer

Solution code:
#何でこのプログラムで通らないか分からん
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a, b, c, d, e, f = MI()
    max_sw=a
    max_s=0
    for an in range(f // (100 * a) + 1):
        for bn in range((f - 100 * a * an) // (100 * b) + 1):
            w = a * an + b * bn
            if w == 0: continue
            if 100 * w > f: break
            for cn in range(100):
                dn = (min(w*e,f-100*w)-c*cn)//d
                if dn < 0: break
                #print(an,bn,cn,dn)
                s = c * cn + d * dn
                if s*max_sw>max_s*(s+w*100):
                    max_sw=s+100*w
                    max_s=s
    print(max_sw,max_s)

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

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

def main():
    ww = []
    for aw in range(0, f + 1, 100 * a):
        for bw in range(0, f + 1, 100 * b):
            if aw + bw > f: break
            ww.append(aw + bw)
    ss = []
    for cs in range(0, (f * e + 99) // 100 + 1, c):
        for ds in range(0, (f * e + 99) // 100 + 1, d):
            if cs + ds > f * e: break
            ss.append(cs + ds)
    mx = 0
    ans = [0, 0]
    for w in ww:
        for s in ss:
            if w + s > f or w * e / 100 < s: continue
            if w + s == 0: continue
            p = s / (w + s)
            if p > mx:
                mx = p
                ans = [w + s, s]
    print(*ans)

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

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

def main():
    ww = []
    for an in range(f // (100 * a) + 1):
        for bn in range((f - 100 * a * an) // (100 * b) + 1):
            ww.append(a * an + b * bn)
    ss = []
    for cn in range(f // c + 1):
        for dn in range((f - cn * c) // d + 1):
            ss.append(c * cn + d * dn)
    mx = 0
    ans = [0, 0]
    for w in ww:
        for s in ss:
            if w * 100 + s > f or w * e < s: continue
            if 100*w+s==0:continue
            p = s / (100 * w + s)
            if p > mx:
                mx = p
                ans = [100 * w + s,s]
    print(*ans)

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a, b, c, d, e, f = MI()
    max_p = 0
    ans = [0,0]
    for an in range(f // (100 * a) + 1):
        for bn in range((f - 100 * a * an) // (100 * b) + 1):
            w = a * an + b * bn
            if w == 0: continue
            if 100 * w > f: break
            for cn in range(100):
                dn = (min(w*e,f-100*w)-c*cn)//d
                if dn < 0: break
                s = c * cn + d * dn
                p = s / (w * 100 + s)
                if p > max_p:
                    max_p = p
                    ans = [w * 100 + s, s]
    print(*ans)

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a, b, c, d, e, f = MI()
    max_p = 0
    ans = []
    for an in range(f // (100 * a) + 1):
        for bn in range((f - 100 * a * an) // (100 * b) + 1):
            w = a * an + b * bn
            if w == 0: continue
            if 100 * w > f: break
            for cn in range(100):
                dn = (min(w*e,f-100*w)-c*cn)//d
                if dn < 0: break
                s = c * cn + d * dn
                p = s / (w * 100 + s)
                if p > max_p:
                    max_p = p
                    ans = [w * 100 + s, s]
    print(*ans)

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a, b, c, d, e, f = MI()
    max_p = 0
    ans = []
    for an in range(f // (100 * a) + 1):
        for bn in range((f - 100 * a * an) // (100 * b) + 1):
            w = a * an + b * bn
            if w == 0: continue
            if 100 * w > f: break
            for cn in range(min(w * e, f - 100 * w) // c + 1):
                dn = (w * e - c * cn) // d
                s = c * cn + d * dn
                if w * 100 + s > f: continue
                p = s / (w * 100 + s)
                if p > max_p:
                    max_p = p
                    ans = [w * 100 + s, s]
    print(*ans)

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a, b, c, d, e, f = MI()
    max_p=0
    ans=[]
    for an in range(f//(100*a)+1):
        for bn in range((f-100*a*an)//(100*b)+1):
            w=a*an+b*bn
            if w==0:continue
            if 100*w+w*e>f:break
            for cn in range(w*e//c+1):
                dn=(w*e-c*cn)//d
                s=c*cn+d*dn
                p=s/(w*100+s)
                if p>max_p:
                    max_p=p
                    ans=[w*100+s,s]
    print(*ans)






main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a, b, c, d, e, f = MI()
    # [水、砂糖]
    stack = [[min(a,b), 0]]
    ans = [0,0]
    max_p=0
    while stack:
        w, s = stack.pop()
        p = 100 * s / (100 * w + s)
        if p > max_p:
            max_p = p
            ans=[w*100+s,s]
        sugar = False
        if s + c <= w * e and 100 * w + s + c <= f:
            stack.append([w, s + min(w*e-s,f-w-s)//c*c])
            sugar = True
        if s + d <= w * e and 100 * w + s + d <= f:
            stack.append([w, s + min(w*e-s,f-w-s)//d*d])
            sugar = True
        if not sugar:
            if 100 * (w + a) <= f:
                stack.append([w + a, s])
            if 100 * (w + b) <= f:
                stack.append([w + b, s])
    print(*ans)
main()

Submission status: Wrong Answer

Solution code:
import math

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

DP = [-1] * (F + 1)
DP[0] = 0

flag_A = True
flag_B = True
flag_C = True
flag_D = True

while flag_A or flag_B or flag_C or flag_D:

    flag_A = False
    flag_B = False
    flag_C = False
    flag_D = False

    for i in reversed(range(F + 1)):

        if DP[i] != -1:
            if i + 100 * A <= F and DP[i] > DP[i+100*A]:
                DP[i + 100 * A] = DP[i]
                flag_A = True
            if i + 100 * B <= F and DP[i] > DP[i+100*B]:
                DP[i + 100 * B] = DP[i]
                flag_B = True
            if (i / 100 * E) >= DP[i] + C and i + DP[i] + C <= F and DP[i] < (DP[i]+C):
                DP[i] = max(DP[i], DP[i] + C)
                flag_C = True
            if (i / 100 * E) >= DP[i] + D and i + DP[i] + D <= F and DP[i] < (DP[i]+D):
                DP[i] = max(DP[i], DP[i] + D)
                flag_D = True

max_i = DP.index(max(DP))
print(max_i+DP[max_i],DP[max_i])

Submission status: Wrong Answer

Solution code:
import math

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

DP = [-1] * (F + 1)
DP[0] = 0

flag_A = True
flag_B = True
flag_C = True
flag_D = True

while flag_A or flag_B or flag_C or flag_D:

    flag_A = False
    flag_B = False
    flag_C = False
    flag_D = False

    for i in reversed(range(F + 1)):

        if DP[i] != -1:
            if i + 100 * A <= F and DP[i+100*A] == -1:
                DP[i + 100 * A] = DP[i]
                flag_A = True
            if i + 100 * B <= F and DP[i+100*B] == -1:
                DP[i + 100 * B] = DP[i]
                flag_B = True
            if (i / 100 * E) >= DP[i] + C and i + DP[i] + C <= F and DP[i] < (DP[i]+C):
                DP[i] = max(DP[i], DP[i] + C)
                flag_C = True
            if (i / 100 * E) >= DP[i] + D and i + DP[i] + D <= F and DP[i] < (DP[i]+D):
                DP[i] = max(DP[i], DP[i] + D)
                flag_D = True

max_i = DP.index(max(DP))
print(max_i+DP[max_i],DP[max_i])