P2705 Balls

Description

There are $R$ red boxes and $B$ blue boxes, and also $R$ red balls and $B$ blue balls. Each box can contain at most one ball, and every ball must be placed in a box. - If a red ball is placed in a red box, the score is $C$. - If a blue ball is placed in a blue box, the score is $D$. - If a red ball is placed in a blue box, the score is $E$. - If a blue ball is placed in a red box, the score is also $E$. Now given $R,B,C,D,E$. How should we place the balls into the boxes to maximize the total score? Output the maximum total score.

Input Format

A single line with $5$ integers, which are $R,B,C,D,E$.

Output Format

A single integer, representing the maximum total score.

Explanation/Hint

### Constraints For all testdata, $1 \le R \le 100$, $1 \le B \le 100$, $-1000 \le C,D,E \le 1000$. Translated by ChatGPT 5