Zhan, tired after the contest, gave the only task that he did not solve during the…
- User
Zhan, tired after the contest, gave the only task that he did not solve during the contest to his friend, Sungat. However, he could not solve it either, so we ask you to try to solve this problem.
You are given an array a1,a2,…,an of length n . We can perform any number (possibly, zero) of operations on the array.
In one operation, we choose a position i (1≤i≤n−1 ) and perform the following action:
ai:=ai−1 , and ai+1:=ai+1+1 . Find the minimum possible value of max(a1,a2,…,an)−min(a1,a2,…,an) .
Input Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤105 ). The description of the test cases follows.
The first line of each test case contains an integer n (1≤n≤2⋅105 ).
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤1012 ).
The sum of n over all test cases does not exceed 2⋅105 .
Output For each test case, output a single integer: the minimum possible value of max(a1,a2,…,an)−min(a1,a2,…,an) .|
hellpppp gooodddd
give correct c++
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.