CitadelOA #11
Optimal Team Size with Skill Bounds
估计困难可在线判题
Developer i has skill i (1-based). If selected, developer i requires that at most lower[i] team members have lower skill and at most higher[i] have higher skill. Find the largest team in which everyone's requirements are satisfied.
输入格式
The first line contains n, the second line contains lower, and the third line contains higher; 0≤array values<n. The original OCR025 states n≤200000 and 026 states n≤2000000; this site keeps the wider original domain 1≤n≤2000000 and does not narrow it to the 200,000 of the curated page.
输出格式
Output a single integer, the answer.
样例 1
输入:
5
1 3 2 2 2
2 2 1 1 3
输出:
3
样例 2
输入:
5
0 4 2 3 3
0 1 3 2 4
输出:
3
样例 3
输入:
2
0 0
0 0
输出:
1
样例说明
The outputs of the three public examples are, in order: 3; 3; 1. These answers were verified by independent enumeration or direct simulation.