Problem Statement | |||||||||||||
There is a grass field that is represented by a 1000 by 1000 grid. Initially, a rabbit is present on the square located at coordinates (1,1) (1-based). The rabbit can move to a horizontally or vertically adjacent square in one second and can only move that way.
You are going to trap the rabbit. To do so, you have set some traps. The i-th trap is located on a square given by trapX[i] and trapY[i] as its X and Y coordinates (1-based) respectively. Return the minimum number of seconds so that after this time has passed there is a non-zero chance that the rabbit has fallen into one of your traps (the rabbit falls into one of your traps if it is in the same square as one of your traps). | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | trapX will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | trapY will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | trapX and trapY will contain the same number of elements. | ||||||||||||
- | Each element of trapX and trapY will be between 1 and 1000, inclusive. | ||||||||||||
- | All traps will have distinct locations. | ||||||||||||
- | No trap will be located at coordinates (1,1). | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|