Source Code
#include<iostream>
#include<algorithm>
using namespace std ;
int main()
{
  int n, p=0 ,l = 0  ;
  cin>>n;

  int arr[n];
  for(int i = 0 ; i<n ; i++)
 {
     cin>>arr[i];
     p += arr[i];
     if(p <=0 ) {l+=abs(p)+1; p+=l;}

 }
 cout<<l;
}
Copy
Zeina The Business Owner Joud
GNU G++17
2 ms
672 KB
Wrong Answer