Vojnici
Perica is playing a game on his computer. He has n solders, and each of his solders has some strength. There are also n opponent's solders, each with his strength. The strengths of all 2n solders are different - there are no two solders with the same strength. Perica has to assign his n solders to fight the opponent's n solders so that each solder is fighting against one opponent's solder.
Also, each of the opponent's solder is assigned two numbers. The first number represents the amount of points Perica's wins if that opponent's solder loses, the second number represents the number of points Perica loses if that opponent's solder wins!
Perica has to assign each of his n solders to fight against exactly one of the opponent's solders so that the number of total points is maximized. In the fight, a solder with higher strength always wins!
Your job is to find the maximal number of points Perica can win.
- From the second line read n integers representing the strengths of n Perica's solders
- From the third line read n integers representing the strength of n opponent's solders
- From the fourth line read n integers representing the number of points Perica will win if the corresponding opponent's solder loses the fight.
- From the fifth line read n integers representing the number of points Perica will lose if the corresponding opponent's solders wins.
All the strengths are in the interval [0, 2000000000], and all the points are in the interval [0, 1000].
Input:
3
9 12 3
4 5 6
10 2 7
5 3 1Output:
14Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.