#P14576. Lamborghini (Remix)

    ID: 13417 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>贪心二分洛谷原创O2优化洛谷月赛双指针 two-pointer

Lamborghini (Remix)

Description

The cursor is an indicator that can appear between two adjacent characters in a line of code, at the end of a line of code, or at the beginning of a line of code. For example, as shown in the figure below:

These three vertical lines represent the cursors.

In modern code editors, we can typically place multiple cursors at the same time.

When the left arrow key is pressed, all cursors will simultaneously move one character to the left. Specifically, the cursor at the beginning of the current line will move to the end of the previous line, and the cursor at the beginning of the first line will disappear.

When the right arrow key is pressed, all cursors will simultaneously move one character to the right. Specifically, the cursor at the end of the current line will move to the beginning of the next line, and the cursor at the end of the last line will disappear.


Now, Simons has a piece of code with nn lines. The length of the ii-th line is aia_i (i.e., the ii-th line is a string of length aia_i). Simons wants to know the maximum number of cursors that can be placed in the same line after pressing the arrow keys multiple times, assuming that he initially places the cursors at the ends of some lines.

You only need to output this maximum value.

Input Format

Each test contains multiple test cases.

For each test:

The first line contains an integer TT, representing the number of test cases.

For each test case:

The first line contains an integer nn, representing the number of lines of code.

The next line contains nn integers separated by spaces, where the ii-th integer aia_i represents the length of the code in the ii-th line.

Output Format

For each test case, output a single integer on one line, representing the answer.

3
7
24 20 20 12 6 6 22
10
10 7 2 3 5 6 4 13 21 30
5
2 3 4 5 6
3
6
2

Hint

Sample 1 Explanation

This sample describes the following code:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int pi=3.14;
int a;
int b;
#define ld long double

Clearly, the lengths of the lines of code are as follows: 24,20,20,12,6,6,2224,20,20,12,6,6,22.

Simons can place cursors at the end of lines 4,5,64,5,6:

By repeatedly pressing the left arrow key, these 33 cursors can all appear simultaneously in the second line:

Alternatively, by repeatedly pressing the right arrow key, these 33 cursors can all appear simultaneously in the seventh line:

It can be proven that there is no way to place more cursors on the same line.

Data Range

For 100%100\% of the data, the constraints are: 1T101\le T\le 10, 1n2×1051 \le n \le 2\times 10^5, and 1ai1091 \le a_i \le 10^9.

Subtask nn \le Special Properties Score
Subtask 1 2020 None 2020
Subtask 2 200200
Subtask 3 50005000
Subtask 4 2×1042 \times 10^4 ai1000a_i \le 1000
Subtask 5 2×1052 \times 10^5 None