Codeforces Round 763 (Div. 2)
C
Balanced Stone Heaps
Codeforces
1600
原题
← BD →
翻译中…

There are $n$ heaps of stone. The $i$-th heap has $h_i$ stones. You want to change the number of stones in the heap by performing the following process once:

翻译中…
  • You go through the heaps from the $3$-rd heap to the $n$-th heap, in this order.
  • Let $i$ be the number of the current heap.
  • You can choose a number $d$ ($0 \le 3 \cdot d \le h_i$), move $d$ stones from the $i$-th heap to the $(i - 1)$-th heap, and $2 \cdot d$ stones from the $i$-th heap to the $(i - 2)$-th heap.
  • So after that $h_i$ is decreased by $3 \cdot d$, $h_{i - 1}$ is increased by $d$, and $h_{i - 2}$ is increased by $2 \cdot d$.
  • You can choose different or same $d$ for different operations. Some heaps may become empty, but they still count as heaps.
翻译中…

What is the maximum number of stones in the smallest heap after the process?

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 2\cdot 10^5$). Description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($3 \le n \le 2 \cdot 10^5$).

翻译中…

The second lines of each test case contains $n$ integers $h_1, h_2, h_3, \ldots, h_n$ ($1 \le h_i \le 10^9$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, print the maximum number of stones that the smallest heap can contain.

翻译中…

Note

翻译中…

In the first test case, the initial heap sizes are $[1, 2, 10, 100]$. We can move the stones as follows.

翻译中…
  • move $3$ stones and $6$ from the $3$-rd heap to the $2$-nd and $1$ heap respectively. The heap sizes will be $[7, 5, 1, 100]$;
  • move $6$ stones and $12$ stones from the last heap to the $3$-rd and $2$-nd heap respectively. The heap sizes will be $[7, 17, 7, 82]$.
翻译中…

In the second test case, the last heap is $1$, and we can not increase its size.

翻译中…

In the third test case, it is better not to move any stones.

翻译中…

In the last test case, the final achievable configuration of the heaps can be $[3, 5, 3, 4, 3, 3]$.

翻译中…

样例

Input #1
4
4
1 2 10 100
4
100 100 100 1
5
5 1 1 1 8
6
1 2 3 4 5 6
Output #1
7
1
1
3
InputCopy OutputCopy
题目信息
题号
1623C
时间限制
1 s
内存限制
256 MB
标签
二分
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。