What is the error in my code?

#include
#include
using namespace std;
main()
{
int ts;
cin>>ts;
int a[100];
int k = 0;
int ms;
while(ts–)
{
int n;
cin>>n;
int arr[n];
int k = 0;
int cs;
int ms = 0;
for(int i = 0 ; i < n ; i++)
{
cin>>arr[i];
}
for(int i = 0 ; i < n ; i++)
{
cs = arr[i];
for(int j = i + 1 ; j < n ; j++)
{
cs = cs + arr[j];
if(cs > ms)
{
ms = cs;
}
}
}
a[ts] = ms;
}
for(int i = ts ; i >= 0 ; i–)
{
cout<<a[i];
}
}

@dhruvtrehan45 your code time complexity is O(n2) it will give tle ,
try to solve it in O(n)

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.