cswork / OA打开练习工作台

AmazonOA #164

Find Maximum Pairs

估计中等可在线判题

考点(AI 标注)贪心调度双指针滑窗

There are two groups of n numbers each; choose a frontend and a backend to form a pair, using each element at most once. Only pairs in which the frontend value is strictly greater than the backend value count; maximize their number.

输入格式

The first line contains n, the second line contains the frontends, and the third line contains the backends. 1≤n≤100000, values in 1..10^9.

输出格式

Output a single integer answer.

样例 1

输入:

3
3 1 5
2 2 4

输出:

2

样例 2

输入:

2
2 2
2 2

输出:

0

样例 3

输入:

1
10
1

输出:

1

样例说明

Example 1: pair 3 with 2 and 5 with 4 for 2 pairs; 1 cannot beat any backend. Example 2: equality does not satisfy strictly greater, so there are 0 pairs. Example 3: 10>1, so 1 pair.