結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー mkawa2mkawa2
提出日時 2023-05-19 22:47:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 172 ms / 3,000 ms
コード長 2,180 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 77,228 KB
最終ジャッジ日時 2023-08-23 00:50:29
合計ジャッジ時間 10,147 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
75,552 KB
testcase_01 AC 143 ms
76,520 KB
testcase_02 AC 158 ms
76,760 KB
testcase_03 AC 136 ms
76,928 KB
testcase_04 AC 125 ms
76,564 KB
testcase_05 AC 127 ms
76,168 KB
testcase_06 AC 114 ms
76,172 KB
testcase_07 AC 115 ms
76,336 KB
testcase_08 AC 115 ms
76,348 KB
testcase_09 AC 140 ms
76,876 KB
testcase_10 AC 121 ms
76,408 KB
testcase_11 AC 134 ms
76,332 KB
testcase_12 AC 135 ms
76,532 KB
testcase_13 AC 157 ms
77,228 KB
testcase_14 AC 150 ms
76,576 KB
testcase_15 AC 143 ms
76,676 KB
testcase_16 AC 129 ms
76,748 KB
testcase_17 AC 136 ms
76,164 KB
testcase_18 AC 138 ms
76,548 KB
testcase_19 AC 140 ms
76,528 KB
testcase_20 AC 134 ms
76,352 KB
testcase_21 AC 131 ms
76,360 KB
testcase_22 AC 142 ms
77,068 KB
testcase_23 AC 132 ms
76,356 KB
testcase_24 AC 146 ms
76,504 KB
testcase_25 AC 143 ms
76,592 KB
testcase_26 AC 136 ms
76,820 KB
testcase_27 AC 129 ms
76,672 KB
testcase_28 AC 138 ms
76,944 KB
testcase_29 AC 148 ms
76,724 KB
testcase_30 AC 129 ms
76,388 KB
testcase_31 AC 158 ms
76,400 KB
testcase_32 AC 172 ms
76,600 KB
testcase_33 AC 158 ms
76,372 KB
testcase_34 AC 152 ms
76,296 KB
testcase_35 AC 165 ms
76,200 KB
testcase_36 AC 78 ms
75,536 KB
testcase_37 AC 70 ms
71,352 KB
testcase_38 AC 83 ms
75,524 KB
testcase_39 AC 80 ms
75,540 KB
testcase_40 AC 78 ms
75,664 KB
testcase_41 AC 145 ms
76,416 KB
testcase_42 AC 123 ms
75,976 KB
testcase_43 AC 122 ms
76,456 KB
testcase_44 AC 112 ms
76,460 KB
testcase_45 AC 114 ms
76,476 KB
testcase_46 AC 111 ms
76,016 KB
testcase_47 AC 85 ms
75,576 KB
testcase_48 AC 78 ms
75,480 KB
testcase_49 AC 95 ms
76,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
md = 10**9+7
# md = 998244353

def solve():
    a, b, c = LI()
    x, y, z, w = LI()
    ans = 0
    if x+y+z >= w*2:
        pre = 0
        for _ in range(2):
            for i in range(min(a, b)+1):
                j = min(b-i, c)
                k = min(a-i, c-j)
                cur = x*i+y*j+z*k+pre
                if cur > ans: ans = cur
                k = min(a-i, c)
                j = min(b-i, c-k)
                cur = x*i+y*j+z*k+pre
                if cur > ans: ans = cur
            if a and b and c:
                a, b, c = a-1, b-1, c-1
                pre = w
    else:
        for l in range(min(a, b, c)+1):
            i = min(a-l, b-l)
            j = min(b-l-i, c-l)
            cur = x*i+y*j+w*l
            if cur > ans: ans = cur

            j = min(b-l, c-l)
            k = min(c-l-j, a-l)
            cur = y*j+z*k+w*l
            if cur > ans: ans = cur

            i = min(a-l, b-l)
            k = min(a-l-i, c-l)
            cur = x*i+z*k+w*l
            if cur > ans: ans = cur

            j = min(b-l, c-l)
            i = min(a-l, b-j-l)
            cur = x*i+y*j+w*l
            if cur > ans: ans = cur
        
            k = min(c-l, a-l)
            j = min(b-l, c-l-k)
            cur = y*j+z*k+w*l
            if cur > ans: ans = cur
        
            k = min(a-l, c-l)
            i = min(a-l-k, b-l)
            cur = x*i+z*k+w*l
            if cur > ans: ans = cur
    print(ans)

for _ in range(II()): solve()
0