1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;

bool canDistribute(int m){
    vector<int> players(n, 0);
    players[0] = m;

    for (int i = 0; i < n; i++){
        int p = players[i];
        int count = 0;

        for (int x = 0; x < p; x++){
            for (int y = x + 1; y < p; y++){
                for (int z = y + 1; z < p; z++){
                    count++;
                }
            }
        }

        if (count < a[i]){
            return false;
        } 

        if (i < n - 1) {
            players[i + 1] = max(2, players[i] - 1);
        }
    }

    return true;
}

int main(){
    int t;
    cin >> t;
    while (t--){
        cin >> n;
        a.resize(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        int m = 3;
        while (!canDistribute(m)){
            m++;
        }
        cout << m << "\n";
    }

    return 0;
}