I am getting first output wrong

#include

using namespace std;

int main()
{

int n;

int a[100];

int cumsum[100]={0};

int current_sum=0;

int maximum_sum=0;

int left=-1;

int right=-1;

int m;
cin>>m;
while(m>0){
//cout<<"Enter the size : "<<endl;
cin>>n;
//cout<<"Enter the elements : "<<endl;

// cout<<"Enter the first element: ";

cin>>a[0];
cumsum[0]=a[0];
for(int i=1;i<n;i++){
    cin>>a[i];
    cumsum[i]=cumsum[i-1] + a[i];
}


for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
            current_sum=0;
    current_sum=cumsum[j]-cumsum[i-1];

    if(current_sum>maximum_sum){
        maximum_sum=current_sum;
        left=i;
        right=j;
        }
    }
}


   cout<<maximum_sum<<endl;
  /*  for(int i=left;i<=right;i++){
        cout<<a[i]<<",";
    }
	*/
	m--;
}
return 0;

}

hello @rajharsh865
pls save ur code here->

and share the generated link with me

@rajharsh865
a)initialise ur variables and array inside while loop
b) handle i==0 case separately

check ur updated code here->

It is showing TLE, how to resolve it. I used cumulative sum but still it is showing TLE, is there any other way?

apply kadane algorithm