問題一覧 > 通常問題

No.2309 [Cherry 5th Tune D] Getting a Head Start on Summer

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 36
作問者 : 👑 Kazun / テスター : Shirotsume
お気に入りにしたユーザー ProblemId : 5701 / 自分の提出
問題文最終更新日: 2023-05-19 23:14:33
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 389 (Until that day when "Cherry Month" is over.) (順位表) の他の問題:

Story

This is "Sakura Shaved Ice" Store No. $3$, a slightly out-of-season shaved ice shop that opened today. Huh? This shop does not sell shaved ice individually !!?

Problem Statement

Cherry has opened an out-of-season shaved ice shop. This shop sells $3$ kinds of shaved ice: strawberry flavor, melon flavor, and blue Hawaii flavor.

Today, Cherry has prepared $A$ servings of strawberry flavor, $B$ servings of melon flavor, and $C$ servings of blue Hawaii flavor.

Cherry cannot make any more shaved ice today.

Cherry has decided to sell these servings of shaved ice in sets as follows. It is impossible to sell shaved ice in any way other than these $4$ kinds of sets.

  • A set of $1$ serving each of strawberry flavor and melon flavor is sold for $X$ yen.
  • A set of $1$ serving each of melon flavor and blue Hawaii flavor is sold for $Y$ yen.
  • A set of $1$ serving each of blue Hawaii flavor and strawberry flavor is sold for $Z$ yen.
  • A set of $1$ each of strawberry flavor, melon flavor, and blue Hawaii flavor is sold for $W$ yen.

Find the maximum possible sales (the total of the selling prices of the sets sold) that Cherry can earn today.

Solve $T$ test cases.

Constraints

  • $1 \leq T \leq 10$.
  • Constraints for each test case
    • $0 \leq A,B,C \leq 10^5$.
    • $1 \leq X,Y,Z,W \leq 10^9$.
  • All input values are integers.

Input

$T$
$\text{Testcase}_1$
$\text{Testcase}_2$
$\vdots$
$\text{Testcase}_T$

Each test case is in the following format.

$A$ $B$ $C$
$X$ $Y$ $Z$ $W$

Output

The output consists of $T$ lines. On line $t~(1 \leq t \leq T)$, print the answer to test case $t$ as an integer on $1$ line.

Do not forget the newline at the end.

Sample

Sample 1
Input
3
2 3 2
2 2 2 3
100 0 0
1000 2000 3000 4000
41421 73205 23456
314159265 358979323 846264338 327950288
Output
7
0
25493847507853

  • [Test case $1$]

    If Cherry acts as follows, she earns $7$ yen in sales.

    • She sells $1$ set of strawberry flavor and melon flavor, earning $X=2$ yen in sales.
    • She sells $1$ set of melon flavor and blue Hawaii flavor, earning $Y=2$ yen in sales.
    • She sells $1$ set of strawberry flavor, melon flavor, and blue Hawaii flavor, earning $W=3$ yen in sales.

    It can also be proved that earning more than $7$ yen in sales is impossible. Therefore, the answer is $7$ yen.

  • [Test case $2$]

    Cherry cannot make any set no matter what she does. Since she cannot sell any shaved ice, the answer is $0$ yen.

    Note that shaved ice of the same flavor cannot be sold as a set.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。