AmazonOA #204
Get Maximum Pairs
Estimated MediumJudge-ready
Topics (AI-labelled)GreedyTwo Pointers
Each of two groups has n servers, and each server can be used at most once. Pair them freely; only pairs whose front-end quality is strictly greater than the back-end quality count. Find the maximum number of pairs.
Input
The first line contains n, the second line the front-end qualities, and the third line the back-end qualities. This site uses 1≤n≤100000, 1≤quality≤10^9.
Output
Output a single integer, the answer.
Example 1
Input:
3
3 1 5
2 2 4
Output:
2
Example 2
Input:
2
2 2
2 2
Output:
0
Example 3
Input:
1
10
1
Output:
1
Example notes
The answers are 2, 0 and 1; ties do not count as wins.
Editorial
Loading solution…