#K5006. Maximum Non-overlapping Events

    ID: 28780 Type: Default 1000ms 256MiB

Maximum Non-overlapping Events

Maximum Non-overlapping Events

You are given a set of events, each defined by a start time and an end time. Your task is to determine the maximum number of events that can be attended such that no two events overlap.

An event is represented as a pair \( (s, e) \) where \( s \) is its start time and \( e \) is its end time. Two events \( (s_1, e_1) \) and \( (s_2, e_2) \) are considered non-overlapping if \( s_2 > e_1 \).

Input/Output: The input is given via standard input. The first line contains an integer \( n \), the number of events. Each of the following \( n \) lines contains two integers representing an event's start time and end time separated by a space. The output should be printed to standard output, and it is a single integer representing the maximum number of non-overlapping events that can be attended.

inputFormat

The input is provided in the following format via stdin:

n
s1 e1
s2 e2
... 
sn en

Here, n is the number of events, and each of the next n lines contains the start and end times of an event.

outputFormat

The output is a single integer printed to stdout, representing the maximum number of non-overlapping events.

## sample
1
1 2
1