#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int sum=0;
int ms=0;
while(n>0){
int target;
cin>>target;
int a[1000];
for(int i=0;i<target;i++){
cin>>a[i];
}
for(int i=0;i<target;i++){
sum=sum+a[i];
if(sum<0){
sum=0;
}
ms=max(sum,ms);
}
nā;
cout<<endl<<ms<<endl;
}
return 0;
}
What's the error please help
THis is not the correct way to solve this problem. You must use kadanes algotithm to solve this. Please have a look at that