← 返回 microsoft 的题目列表Schedule a New Calendar Event Without Overlap
类型:online_judge
Problem: Schedule a New Calendar Event Without Overlap
You maintain a calendar calendar containing multiple existing events. Each event is an interval:
event = (start, end)
assume start < end
times are integers
The current calendar is valid: no two existing events overlap.
Given a new event new_event = (s, e), determine whether it can be added so that the calendar still has no overlaps.
Overlap definition
Two events overlap if their time intervals intersect.
Assume half-open intervals [start, end) (end is not included).
Input (stdin)
Line 1: integer n, number of existing events
Next n lines: start end
Last line: s e for the new event
Output (stdout)
Print true or false
Constraints
0 <= n <= 2e5
0 <= start, end, s, e <= 1e9
Examples
See the 5 test cases in the Chinese version.
Example
Input
3
1 3
5 7
8 10
3 5
Output
true