Floor and Ceil in a Sorted Array
Find the floor (largest element ≤ target) and ceil (smallest element ≥ target) in a sorted array.
Input format
The first line contains N and the target. The second line contains N integers in non-decreasing order.
Output format
Print two values: the floor (largest element ≤ target) and the ceil (smallest element ≥ target), separated by a space. Print -1 in place of a value that does not exist.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
5 5
1 2 4 6 10Expected output
4 6Example 2
Input
3 0
1 2 3Expected output
-1 1