Maximum Compatible Meetings
Choose as many intervals as possible so that no two chosen intervals share any point (endpoints inclusive). Print the maximum count.
Input: the first line has N; the next N lines each have two integers a b (a ≤ b).
Output: the maximum number of pairwise disjoint intervals.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ a ≤ b ≤ 106
Sample Tests
Input 1
4 1 3 2 4 3 5 6 7
Output 1
2
Input 2
2 1 5 2 3
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.