結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2023-05-19 23:54:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,327 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 77,116 KB
最終ジャッジ日時 2023-08-23 02:00:09
合計ジャッジ時間 9,400 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 103 ms
76,324 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 107 ms
76,252 KB
testcase_08 AC 107 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 108 ms
76,080 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,484 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,340 KB
testcase_32 AC 132 ms
76,420 KB
testcase_33 AC 131 ms
76,484 KB
testcase_34 AC 124 ms
76,144 KB
testcase_35 AC 126 ms
76,392 KB
testcase_36 WA -
testcase_37 AC 74 ms
71,188 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 117 ms
76,364 KB
testcase_43 AC 94 ms
76,136 KB
testcase_44 AC 90 ms
75,512 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 82 ms
75,448 KB
testcase_48 AC 79 ms
75,548 KB
testcase_49 AC 84 ms
75,600 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,w):

    count = 0

    ## abc
    for x in range(min(a,b,c)+1):

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

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

                if i+j+x > a:
                    break

                num = i * x + j * z + x*w
                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 > 10:
            base += (mi-10)*w
            a -= mi-10
            b -= mi-10
            c -= mi-10
        
        base += calc2(a,b,c,x,y,z,w)

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

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