Lina and Abdullah are playing darts for $n$ rounds, Lina's points in the $i_{th}$ round are denoted by $a_i$ and Abdullah's points by $b_i$.
The total score of the game is calculated as $total = \sum_{i=1}^{n} a_i-b_i$.
If $total>0$ then Lina wins, if $total<0$ then Abdullah wins, otherwise it's a draw!
If each player can swap at most 2 different scores from two different rounds, who will win if they both make their swaps optimally?
The first line will contain an integer $n$ $(1 \le n \le 10^5)$, the number of rounds.
The second line will contain $n$ space-separated integers, the values $a_i$ $(0 \le a_i \le 10^9)$, the scores of Lina in the $i_{th}$ round.
The third line will contain $n$ space-separated integers, the values $b_i$ $(0 \le b_i \le 10^9)$, the scores of Abdullah in the $i_{th}$ round.
Output the resulting value of $total$ if both players use their swaps optimally. See the notes for the definition of optimal play.
Playing optimally means that every player will choose his swap in such a way that whatever the other player chooses, it'll maximize the probability that he will win.
Input | Output |
---|---|
3 1 4 2 3 0 5 Copy
|
-1 Copy
|
4 5 2 1 4 4 2 3 2 Copy
|
1 Copy
|