No.2175 Exciting Combo
Problem Statement
Core is hooked on a fighting game.
In this game, you can use $3$ types of moves numbered $1,2,3$.
Using move $i$ $(1 \leq i \leq 3)$ $1$ time deals $A_{i}$ damage to the enemy. Here, $A_{1} \leq A_{2} \leq A_{3}$.
Also, using these moves $1$ time each in the order $1 \to 2 \to 3$ triggers a combo,
which deals an additional $B$ damage to the enemy on top of the damage from the $3$ moves.
When you perform the operation "freely choose $1$ of moves $1,2,3$ and use it $1$ time" $3$ times,
find the maximum damage that can be dealt to the enemy.
Constraints
$1 \leq A_{1} \leq A_{2} \leq A_{3} \leq 100$
$1 \leq B \leq 100$
All inputs are integers.
Input
The input is given in the following format.
$A_{1}$ $A_{2}$ $A_{3}$ $B$
The $1$st line contains $A_{1}, A_{2}, A_{3}, B$ in this order, separated by single spaces.
Output
Output the answer on $1$ line.
Sample
Sample 1
Input
1 2 3 4
Output
10
It is best to use moves $1 \to 2 \to 3$ in this order, $1$ time each.
In this case, move $1$ deals $1$ damage, move $2$ deals $2$ damage, and move $3$ deals $3$ damage to the enemy,
and the combo being triggered deals an additional $4$ damage.
Therefore, a total of $1+2+3+4=10$ damage is dealt to the enemy.
It is not possible to deal more damage than this to the enemy.
Sample 2
Input
3 9 9 3
Output
27
For example, you can use move $2$ $3$ times in a row. In this case, $9 \times 3 = 27$ damage is dealt to the enemy.
If you use moves $1, 2, 3$ in this order, $1$ time each, move $1$ deals $3$ damage, move $2$ deals $9$ damage, move $3$ deals
$9$ damage, and the combo deals $3$ damage to the enemy, but
the total of these is $24$ damage, which is less than $27$ damage.
Sample 3
Input
77 77 77 77
Output
308
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
MasKoaTS