#include
#include
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t!=0)
{
long n;
vectora;
cin>>n;
for(int i=0;i<n;i++)
{
int temp;
cin>>temp;
a.push_back(temp);
}
int cs=0,ms=0;
for(int i=0;i<n;i++)
{
cs=cs+a[i];
if(cs<0)
{
cs=0;
}
ms=max(cs,ms);
}
cout<<ms;
}
return 0;
}
the above code is showing time limit on coding blocks IDE.Why?
Regarding kadanes Algorithm
save your code on the online ide
hey @kushagrathebest, you are not decreasing the value of t, thatswhy loop is running for infinite number of times and you are getting TLE.