| 2 | #include<math.h> |
| 3 | using namespace std; |
| 4 | int main(){ |
| 5 | long long a[100000]; |
| 6 | long long n; |
| 7 | long long c=0,p=0,sum=0; |
| 8 | cin>>n; |
| 9 | for(int i=0;i<n;i++) |
| 10 | cin>>a[i]; |
| 11 | for(int i=0;i<n;i++){ |
| 12 | if(a[i]==-1) |
| 13 | {c++; |
| 14 | } |
| 15 | else |
| 16 | {p+=a[i]; |
| 17 | } |
| 18 | if(p<=0) |
| 19 | {sum++; |
| 20 | c--; |
| 21 | } |
| 22 | else if(c!=0) |
| 23 | {p--; |
| 24 | c--; |
| 25 | } |
| 26 | } |
| 27 | cout<<sum<<endl; |
| 28 | return 0; |
| 29 | |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected