#P2813. 母舰
母舰
Description
In player A’s space war game, a powerful mothership often decides the outcome of a war. The attack power of a mothership cannot be matched by ordinary MAs (Mobile Armor).
A mothership consists of several attack systems and several defense systems. When two motherships duel, one mothership will choose different attack systems to attack the opponent’s defense systems. If the attack power of an attack system is greater than the defense power of a defense system, that defense system will be destroyed. After all defense systems of a mothership have been destroyed, all remaining attacks will hit the enemy mothership itself and deal damage.
In other words, the damage a mothership deals to the opponent depends, to some extent, on how you choose targets.
On a rapidly changing battlefield, choosing optimal targets is crucial. Therefore, you need to implement a battle system to determine the maximum damage your mothership can deal to the opponent.
Input Format
The first line contains two integers and , the number of the opponent’s defense systems and the number of your mothership’s attack systems.
Then follow lines, each with one integer, representing the defense power of each opponent defense system.
Then follow lines, each with one integer, representing the attack power of each of your attack systems.
Output Format
Output a single line with the maximum damage that can be dealt.
3 5
1000
2000
1200
2100
2000
1200
1000
1000
2000
Hint
Sample Explanation #1
The opponent has defense systems with defense values , and you have attack systems with attack values . An optimal plan for the first round is: attacks , attacks , attacks , and and attack the enemy mothership itself, dealing damage.
Constraints
For of the testdata, .
For of the testdata, .
This problem is a reposted problem.
Translated by ChatGPT 5
京公网安备 11011102002149号