結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-05-19 23:49:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,223 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 77,248 KB
最終ジャッジ日時 2023-08-23 01:55:15
合計ジャッジ時間 7,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,600 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 103 ms
76,244 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 106 ms
76,112 KB
testcase_08 AC 106 ms
76,240 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 111 ms
76,412 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 118 ms
76,688 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 126 ms
76,520 KB
testcase_32 AC 131 ms
76,596 KB
testcase_33 AC 130 ms
76,376 KB
testcase_34 AC 124 ms
76,316 KB
testcase_35 AC 123 ms
76,588 KB
testcase_36 WA -
testcase_37 AC 75 ms
71,204 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 114 ms
76,304 KB
testcase_43 AC 93 ms
76,200 KB
testcase_44 AC 89 ms
75,600 KB
testcase_45 AC 92 ms
76,000 KB
testcase_46 AC 95 ms
76,356 KB
testcase_47 AC 79 ms
75,460 KB
testcase_48 AC 77 ms
75,568 KB
testcase_49 AC 82 ms
75,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(a,b,c,x,y,z):

    ret = 0
    ba = a
    bb = b
    bc = c
    if max(x,y,z) == x:
        for i in range(min(a,b)+1):
            count = i*x
            a,b,c = ba,bb,bc
            if z >= y:
                count += z * min(a-i,c)
                c -= min(a-i,c)
                count += y * min(b-i,c)
            else:
                count += y * min(b-i,c)
                c -= min(b-i,c)
                count += z * min(a-i,c)
            ret = max(ret,count)

    elif max(x,y,z) == y:
        for i in range(min(b,c)+1):
            count = i*y
            a,b,c = ba,bb,bc
            if z >= x:
                count += z * min(c-i,a)
                a -= min(c-i,a)
                count += x * min(b-i,a)
            else:
                count += x * min(b-i,a)
                a -= min(b-i,a)
                count += z * min(c-i,a)
            ret = max(ret,count)

    else:
        for i in range(min(a,c)+1):
            count = i*z
            a,b,c = ba,bb,bc
            if y >= x:
                count += y * min(c-i,b)
                b -= min(c-i,b)
                count += x * min(a-i,b)
            else:
                count += x * min(a-i,b)
                b -= min(a-i,b)
                count += y * min(c-i,b)
            ret = max(ret,count)

    return ret


def calc2(a,b,c,x,y,z):

    count = 0

    ## ab
    for i in range(min(a,b)+1):

        ## ac
        for j in range(c+1):

            if i+j > a:
                break

            num = i * x + j * z
            num += min(b-i,c-j)*y
            count = max(count,num)
    return count

def solve():
    a,b,c = map(int,input().split())
    x,y,z,w = map(int,input().split())

    
    ans = 0

    if max(x,y,z) >= w:

        ans = max(ans,calc(a,b,c,x,y,z))

    elif x+y+z >= 2*w:
        ans = max(ans,calc(a,b,c,x,y,z))
        if a*b*c:
            ans = max(ans,calc(a-1,b-1,c-1,x,y,z) + w)


    else:
        mi = min(a,b,c)
        base = 0
        if mi > 5:
            base += (mi-5)*w
            a -= mi-5
            b -= mi-5
            c -= mi-5
        
        base += calc2(a,b,c,x,y,z)

        ans = max(ans,base)
    
    print(ans)

t = int(input())
for _ in range(t):
    solve()
0