#K15821. Longest Event Sequence
Longest Event Sequence
Longest Event Sequence
You are given a set of events, each described by a timestamp and an event id. Your task is to compute the length of the longest sequence of events if the events are sorted by their timestamps. Note that if two events have the same timestamp, they are both considered to be in the sorted order.
The input consists of a number of events followed by each event’s details. The solution should sort the events by the timestamp and then output the total count of events, representing the longest sequence achievable.
More formally, if you are given events \(E = [(t_1, id_1), (t_2, id_2), \dots, (t_n, id_n)]\), then you need to output \(n\) after sorting \(E\) in non-decreasing order of \(t_i\). The problem is straightforward but tests your ability to correctly process input and output on standard streams.
inputFormat
The first line contains an integer \(n\), the number of events. The following \(n\) lines each contain two integers representing the timestamp and the event id of an event, separated by a space.
outputFormat
Output a single integer, the length of the longest sequence of events after sorting them by their timestamps.
## sample5
1 101
3 102
2 103
4 104
5 105
5
</p>