#include
#include
using namespace std;
int maxSubArraySum(long int a[],long int size)
{
long int max_so_far = INT_MIN, max_ending_here = 0;
for (int i = 0; i < size; i++)
{
max_ending_here = max_ending_here + a[i];
if (max_so_far < max_ending_here)
max_so_far = max_ending_here;
if (max_ending_here < 0)
max_ending_here = 0;
}
return max_so_far;
}
int main()
{
long int a[100000],n,t,max_sum[100000];
cin>>t;
cin>>n;
for(int j=0;j<t;j++)
{
for(int i=0;i<n;i++)
{
cin>>a[i];
}
max_sum[j] = maxSubArraySum(a, n);
}
for(int i=0;i<t;i++)
{
cout<<max_sum[i]<<endl;
}
return 0;
}
I AM HAVING A BLANK SCREEN AS OUTPUT WHEN I SUBMIT THIS CODE BUT I GET RUN ERROR WHEN I TAKE THE SIZE OF ARRAY AS 10. WHAT IS WRONG IN THIS CODE??.