#P2705. Maximizing Ball Placement Score
Maximizing Ball Placement Score
Maximizing Ball Placement Score
You are given \( R \) red boxes and \( B \) blue boxes, along with \( R \) red balls and \( B \) blue balls. Each box can hold exactly one ball and every ball must be placed in a box.
The scoring rules are as follows:
- 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 \).
All boxes must be filled, and exactly one ball is placed in each box. Determine the arrangement of balls in boxes to maximize the total score, and output the maximum total score.
Note: All formulas are written in LaTeX format.
inputFormat
The input consists of a single line containing five integers \( R, B, C, D, E \) separated by spaces.
- \( R \): The number of red boxes (and red balls).
- \( B \): The number of blue boxes (and blue balls).
- \( C \): The score for placing a red ball in a red box.
- \( D \): The score for placing a blue ball in a blue box.
- \( E \): The score for placing a ball in a mismatched box (red ball in a blue box or blue ball in a red box).
outputFormat
Output a single integer representing the maximum total score achievable.
sample
3 2 10 10 0
50