ALL. A professor in the Computer, Science departimient'of HackerLand College wants to generate an array: Given ain array of integers of length
n
, arr, and two integer's fand
r
, find another array, brr, such that:
∙:≤
brriji
≤r
- brr[i]
−arr[i]< brr
˙
[i+1]−arr[i+1]
, for every
i
less than - brr[i] brr[it1] for every iless than
n−1
Among all such arrays, return the lexicographically smallest one. If there in not an array that satisfies the conditions, then return an array with the single element
−1.
Example arr
=[1,2,1,2],I=1,r=10
The array
[1,3,3,5]
satisfies given conditions. 1. Each element belongs in the range
[1,10]
. 2. Construct an array crr where,
cr[i]=
brri]
−arr[i]
,
cr=[0,1,2,3]
and it is increasing. 3. The array brr is non-decreasing. brri]-arr[i] for each element is
[0,1,2,3]
1−1=0
Sample Case 1 Sample Input 1 Sample'Output 1
−1
Explanation There is not an array that satisfies the conditions.