Whats the problem in this(max sum sub array)

#include
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
int curSum=0,maxSum=0;
cin>>n;
int a[1000];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
curSum=0;
for(int k=i;k<=j;k++)
{
curSum+=a[k];

        }if(curSum>maxSum)
        {
            maxSum=curSum;
        }
        
        
    }
}cout<<maxSum<<endl;

}

}

@vasugoel0240
Hello Vasu,
a)value of n can be upto 100000 so increase your array size.
b) sum can be big so change your datatype from int to long long.
c) revise kadane algorithm and check its implementation. then modify your code.

suggestion-use coding blocks ide for code sharing.

@vasugoel0240
Hello Vasu,
do u need any help?

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.