#C11946. Maximizing Non-Overlapping Lectures Attendance

    ID: 41318 Type: Default 1000ms 256MiB

Maximizing Non-Overlapping Lectures Attendance

Maximizing Non-Overlapping Lectures Attendance

You are given a set of lectures, each with a start time and an end time. Your task is to determine the maximum number of lectures you can attend without any overlap. Two lectures are considered non-overlapping if the start time of the current lecture is not less than the finish time of the previously attended lecture.

Formally, you are given \(N\) lectures with start times \(s_i\) and end times \(e_i\) for \(i = 1, 2, \dots, N\). You need to select a subset of lectures such that for any two consecutive lectures in your selection, \(s_{j+1} \ge e_j\). The objective is to maximize the count of selected lectures.

inputFormat

The first line contains an integer \(N\), the number of lectures.

Then \(N\) lines follow. Each of these lines contains two space-separated integers \(s\) and \(e\) which represent the start and end times of a lecture.

outputFormat

Output a single integer representing the maximum number of non-overlapping lectures that can be attended.

## sample
5
1 4
2 3
3 5
4 6
5 7
3

</p>