A group of employees at an office is going to play a number game by dividing 2*N employees into two teams of N players. Let call each team as A and B. The rule of the number game is as follows.

  • First, all employees are given a random natural number.
  • Each employee plays the game only once.
  • In each game, one employee from the A and B team each opens their number. The employee with a higher number is determined as a winner and the team where the employee belongs gets 1 point.
  • If the number of both employees are the same, no team gets points.

Here, all employees were given a random natural number. Team A decided who goes first and revealed it to team B. Based on the play order of team A, team B determined their employee order to maximize the total point. At this point, we want to calculate the total points team B will get.
Given an array A containing numbers assigned to employees of team A in order of play and an array B whose i-th element represents numbers given to the i-th employee of team B, write a function solution to return the maximum point that team B can get.

  • A and B have the same length.
  • Length of A and B is between 1 and 100,000.
  • Each element of A and B is natural number less than or equal to 1,000,000,000.
A B result
[5,1,3,7] [2,2,6,8] 3
[2,2,2,2] [1,1,1,1] 0

Example #1
In team A, an employee with number 5 plays the game first, then ones with numbers 1, 3, and 7 play the game in turn.
In team B, when 4th, 2nd, 3rd, and 1st employees play the game in turn, numbers given to them are 8, 2, 6, and 2, in turn. Then, team B gets 3 points by winning the first, second, and third game. This is the total point.

Example #2
Team B always gets 0 points regardless of the play order.

Result Stop
Result of [Run Test] or [Submit] will be displayed here