309094: CF1623C. Balanced Stone Heaps
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Balanced Stone Heaps
题意翻译
你有 $n$ 堆石子,其中第 $i$ 堆里面有 $h_i$ 粒石子。你需要从第 $3$ 堆石子开始从前往后进行操作。设当前为第 $i$ 堆石子,你可以选择一个在 $[0,\frac {h_i}3]$ 的整数 $d$,从第 $i$ 堆石子中取出 $3d$ 粒石子,然后往第 $i-1$ 堆石子里放入 $d$ 粒石子,往第 $i-2$ 堆石子里放入 $2d$ 粒石子。 你需要通过合理设计操作方案,使得数量最少的一堆石子的数量最大。请求出这个最大值。 数据范围: - $t$ 组数据,$1\leqslant t\leqslant 2\times 10^5$。 - $3\leqslant n,\sum n\leqslant 2\times 10^5$。 - $1\leqslant h_i\leqslant 10^9$。 Translated by Eason_AC 2021.12.29题目描述
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?输入输出格式
输入格式
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 $ .
输出格式
For each test case, print the maximum number of stones that the smallest heap can contain.
输入输出样例
输入样例 #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
输出样例 #1
7
1
1
3