#t134. 田忌赛马
田忌赛马
Tian Ji's Horse Racing
Problem Description
Corresponding multiple-choice / true-false questions: https://ti.luogu.com.cn/problemset/1136
You are going to race horses against Tian Ji. Each of you has horses, and you will compete in rounds; in each round both of you send out one horse to decide the winner.
Your horses' speeds are , and Tian Ji's horses' speeds are . Tian Ji sends his horses in order. How should you arrange your lineup to win the most rounds? By coincidence, all your and Tian Ji's horses have pairwise distinct speeds, so there can be no ties.
Input Format
The first line contains an integer .
The second line contains integers , your horses' speeds.
The third line contains integers , Tian Ji's horses' speeds.
Output Format
Output one line containing one integer: the maximum number of rounds you can win.
Sample Input 1
3
1 3 5
2 4 6
Sample Input 2
5
10 3 5 8 7
4 6 1 2 9
Sample Output 1
2
Sample Output 2
5
Sample Explanation
Round 1: Tian Ji sends the horse of speed ; you can send the horse of speed to win this round.
Round 2: Tian Ji sends the horse of speed ; you can send the horse of speed to win this round.
Round 3: Tian Ji sends the horse of speed ; you send the horse of speed , and Tian Ji wins this round.
Thus you win rounds.
Constraints
- ;
- ;
- all horses' speeds are pairwise distinct; no ties occur.