luogu#P2705. 小球
小球
Problem Description
There are red boxes and blue boxes, and also red balls and 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 .
- If a blue ball is placed in a blue box, the score is .
- If a red ball is placed in a blue box, the score is .
- If a blue ball is placed in a red box, the score is also .
Now given . 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 integers, which are .
Output Format
A single integer, representing the maximum total score.
2 3 100 400 200
1400
2 3 100 400 300
1600
Hint
Constraints
For all testdata, , , .
Translated by ChatGPT 5