WeRideOA #9
Meetup Schedule
Estimated MediumJudge-ready
Topics (AI-labelled)GreedyStacks & Heaps
Each investor is available to meet only within the closed interval [firstDay[i], lastDay[i]]; at most one meeting can be scheduled per day. Find the maximum number of meetings that can be scheduled.
The closed intervals and the daily limit in the statement are explicit; the original text lacks constraints, so this site adds upper bounds on dates and counts.
Input
The first line contains n (0≤n≤100000); the second line contains n firstDay values; the third line contains n lastDay values. Dates are 1..10^9, and firstDay[i]≤lastDay[i].
Output
Output the maximum number of meetings.
Example 1
Input:
3
1 2 3
2 3 4
Output:
3
Example 2
Input:
3
1 1 2
1 2 2
Output:
2
Example 3
Input:
0
Output:
0
Editorial
Loading solution…