Chef And Babla Codechef Solution

We Are Discuss About CODECHEF SOLUTION

Chef And Babla Codechef Solution

Chef And Babla Codechef Solution

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

Problem

Chef gives an array  with  elements to Babla. Babla’s task is to find the maximum non-negative integer  such that:

  • No element in the array belongs to the range [−�,�]. In other words, for all (1≤�≤�), either ��<−� or ��>�.

Help Babla to find the maximum non-negative integer  for which the given condition is satisfied or determine if no such  exists.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of multiple lines of input.
    • The first line of each test case contains an integer  — the number of elements in the array.
    • The second line of each test case contains  space-separated integers �1,�2,…,�� representing the array .

Output Format

For each test case, output on a new line, the maximum non-negative integer , satisfying the above condition.
If no such  exists, output −1 instead.

Constraints

  • 1≤�≤105
  • 1≤�≤105
  • −109≤��≤109
  • Sum of  over all test cases does not exceed 2⋅105.

Sample 1:

Input

Output

3
5
8 4 2 5 2
6
7 9 -10 8 12 17
4
0 -3 -1 -10
1
6
-1

Explanation:

Test case 1: The maximum value of  such that no element of the array belongs to the range [−�,�] is 1. All elements of the array are strictly greater than 1.

Test case 2: The maximum value of  such that no element of the array belongs to the range [−�,�] is 6. All positive elements of the array are strictly greater than 6 and negative elements are strictly less than −6.

Test case 3: It is not possible to choose an element  that satisfies the given condition.

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

 

SOLUTION

Here Discuss About Chef And Babla Codechef Solution

SOLUTION

Chef And Babla Codechef Solution

SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *