No.2138 Add Bacon
Problem Statement
Culinary researcher shojin is going to make clam chowder.
Without any bacon added, the clam chowder has a tastiness of $A$ and a calorie count of $B$.
shojin adds at least $0$ grams and at most $C$ grams of bacon (an integer amount). For each $1$ gram of bacon added, the tastiness of the clam chowder increases by $D$ and the calorie count increases by $E$.
The happiness is the value obtained by subtracting the calorie count from the tastiness of the clam chowder. Find the maximum possible happiness.
Constraints
- $1\le A,B,C,D,E\le 1000$
- All inputs are integers.
Input
$A$ $B$ $C$ $D$ $E$
Output
Output the maximum possible happiness.
Sample
Sample 1
Input
2 1 3 6 4
Output
7
- When $0$ grams of bacon are added, the tastiness is $2$ and the calorie count is $1$, so the happiness is $1$.
- When $1$ gram of bacon is added, the tastiness is $8$ and the calorie count is $5$, so the happiness is $3$.
- When $2$ grams of bacon are added, the tastiness is $14$ and the calorie count is $9$, so the happiness is $5$.
- When $3$ grams of bacon are added, the tastiness is $20$ and the calorie count is $13$, so the happiness is $7$.
Sample 2
Input
100 200 300 400 500
Output
-100
Even if it makes him unhappy, shojin must eat the clam chowder.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。