cswork / OA打开练习工作台

WeRideOA #9

Meetup Schedule

估计中等可在线判题

考点(AI 标注)贪心调度单调栈与堆

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.

输入格式

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 the maximum number of meetings.

样例 1

输入:

3
1 2 3
2 3 4

输出:

3

样例 2

输入:

3
1 1 2
1 2 2

输出:

2

样例 3

输入:

0


输出:

0