What's the error it shows run time but pefectly run on cb ide

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int csum=0;
int max=INT_MIN;
int a[1000];
while(n>0){
int k;
cin>>k;
for(int i=0;i<k;i++){
cin>>a[i];
}
int z=1;
max=INT_MIN;
for(int i=0;i<k;i++){
csum=csum+a[i];
if(csum>max){
max=csum;
}
else{
z++;
csum=a[z];
break;
}
}
n–;
cout<<max<<endl;

    }
return 0;

}

hello @pranjuldwivedi120568
check maximum value of n from constraint section. and declare ur array with size greater than that.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.