Description

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.

Constraints
• `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.
Examples
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
내가 제출한 코드가 왜 틀렸는지 프로그래머스 AI에게 물어보세요.
제출 후 채점하기를 눌러 30점 이상인 경우 물어볼 수 있어요.
베타 기간 동안에는 한 문제당 1번만 물어볼 수 있어요.