I have written this code
but it is showing run time error for every case
#include
using namespace std;
int main()
{
int a[100],b[100],k,i,j,cs,ms,n;
cin>>k;
for(i=0;i<k;i++)
{
cin>>n;
for(j=0;j<n;j++)
cin>>a[j];
cs=ms=0;
for(j=0;j<n;j++)
{
cs+=a[j];
if(cs<0)
cs=0;
ms=max(cs,ms);
}
b[i]=ms;
}
for(i=0;i<k;i++)
cout<<b[i]<<endl;
}