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
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
int t;
int n,a;

std::vector<int> u;

bool test(int za){
    int pre=0;
    for(int i=0;i<u.size();i++){
        long long act=0;
        if(u[i])
            act++;
        while(pre*act*(za-pre-act)+(act*(act-1))/2*(za-act)+(act*(act-1)*(act-2)/6)<u[i])
            act++;
        pre+=act;
        //std::cout<<act<<" ";
        if(pre>za){
            //std::cout<<"\n\n";
            return false;
        }
    }
    //std::cout<<"\n\n";
    return true;
}

int binsearch(int a,int b){
    if(b==a+1)
        return b;
    else{
        //std::cout<<a<<" "<<b<<" "<<(a+b)/2<<std::endl;
        if (!test((a+b)/2))
            return binsearch((a+b)/2,b);
        else
            return binsearch(a,(a+b)/2);
        
    }
}
int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(NULL);
    std::cin>>t;
    //t=1;
    for(int tt=0;tt<t;tt++){
        u.clear();
        std::cin>>n;
        //n=200000;
        for(int i=0;i<n;i++){
            std::cin>>a;
            //a=1000000;
            u.emplace_back(a);
        }
        std::cout<<binsearch(1,200008)<<std::endl;
    }
    
    
    
}