#K79832. Task Completion Without Overlap

    ID: 35396 Type: Default 1000ms 256MiB

Task Completion Without Overlap

Task Completion Without Overlap

You are given n tasks, each represented by an interval defined by its start and end times \(s\) and \(e\) respectively. Your task is to determine if it is possible to complete all tasks one after another without any overlap. Two tasks are considered non-overlapping if the start time of a task is not less than the end time of the previous task.

In other words, given a list of intervals \(\{(s_i, e_i)\}_{i=1}^{n}\), check if after ordering them (in an optimal order) the following condition holds for all \(i\):

\[ s_{i+1} \geq e_i \]

If the condition holds, print YES; otherwise, print NO.

inputFormat

The first line contains an integer n, representing the number of tasks.

The following n lines each contain two integers s and e separated by a space, representing the start and end time of a task.

outputFormat

Output a single line containing either YES if it is possible to complete the tasks without any overlaps, or NO otherwise.

## sample
3
1 3
2 4
3 5
NO