Problem Statement | |||||||||||||
You will be given a int[] A that contains N elements and an int P. Return the number of distinct integer values of X for which the following inequality is true: |A0 - X| + |A1 - X| + ... + |AN-1 - X| ≤ P | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
| - | A will contain between 1 and 50 elements, inclusive. | ||||||||||||
| - | Each element of A will be between -1,000,000,000 and 1,000,000,000 inclusive. | ||||||||||||
| - | P will be between 0 and 1,000,000,000 inclusive. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||
| 3) | |||||||||||||
| |||||||||||||
| 4) | |||||||||||||
| |||||||||||||