問題一覧 > 通常問題

No.2138 Add Bacon

レベル : / AI推定難易度 : 77 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 255
作問者 : 👑 箱星 / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 8877 / 自分の提出
問題文最終更新日: 2022-11-28 16:47:10
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
Advent Calendar Contest 2022 (順位表) の他の問題:

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$.
Therefore, the maximum 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もしくは右上の雲マークをクリックしてアカウントを作成してください。