Related to maximum subarray sum code submision

Code is running fine on offline ide but gives run error on coding blocks.
Then i chaged all to long long int but now gives TLE message.
Please help!

Below is my code:
#include
#include
using namespace std;
int main()
{
long long int t, n;
cin >> t;
while (t–)
{
cin >> n;
int a[n];
for (long long int i = 0; i < n; ++i)
{
cin >> a[i];
}
long long int max_sum = INT_MIN;
long long int sum = 0;
for (long long int i = 0; i < n; ++i)
{
for (long long int j = i; j < n; ++j)
{
sum = 0;
for (long long int k = i; k <= j; ++k)
{
sum += a[k];
}
if (sum > max_sum)
{
max_sum = sum;
}
}
}
cout << max_sum << “\n”;
}

return 0;

}

hello @yashvats

ur algorithm has o(n^3) time complexity becuase of that it is giving tle.

use kadane algorithm for this problem