Test cases are not passing

used kadane’s algo
#include<bits/stdc++.h>
using namespace std;
int main() {
int t=0;
cin>>t;
while(t>0)
{
int n=0;
cin>>n;
int a[1000]={0};
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int csum=0,maxsum=0;
for(int i=0;i<n;i++)
{
csum+=a[i];
if(csum<0) csum=0;
else if(csum>maxsum) maxsum=csum;
}
cout<<maxsum<<endl;
t–;
}
return 0;
}

This logic will fail when all the elements of the array are negative, it will give 0 as output.

i corrected it now. its working on ide but again test case not passing. please have a look

@jainarpit0210 try using long long

https://ide.codingblocks.com/s/575342 still not working. can you point out the mistake

increase size of the array according to constraints

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.