Problems > One Meeting Room

One Meeting Room

Difficulty: 1200 3500 ms 128 MB

intervals sorting

Meetings [start, end) are given. Can one person attend ALL of them (a meeting ending at time t does not clash with one starting at t)?

Input: the first line has N; the next N lines each have start and end.

Output: YES or NO.

Constraints:

  • 1 ≤ N ≤ 105
  • 0 ≤ start < end ≤ 106

Sample Tests

Input 1
3
0 30
5 10
15 20
Output 1
NO
Input 2
2
5 8
8 12
Output 2
YES

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.