Attend the Most Events
Each event spans days [start, end] and you can attend one event per day (any day within its span). Maximize the number of events attended.
Input: the first line has N; each of the next N lines has an event's start and end day.
Output: the maximum number of events attendable.
Constraints:
- 1 ≤ N ≤ 105
- 1 ≤ start ≤ end ≤ 105
Sample Tests
Input 1
3 1 2 2 3 3 4
Output 1
3
Input 2
2 1 1 1 1
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.