#P2705. 小球

小球

Description

There are RR red boxes and BB blue boxes, and also RR red balls and BB 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 CC.
  • If a blue ball is placed in a blue box, the score is DD.
  • If a red ball is placed in a blue box, the score is EE.
  • If a blue ball is placed in a red box, the score is also EE.

Now given R,B,C,D,ER,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 55 integers, which are R,B,C,D,ER,B,C,D,E.

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, 1R1001 \le R \le 100, 1B1001 \le B \le 100, 1000C,D,E1000-1000 \le C,D,E \le 1000.

Translated by ChatGPT 5