Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a,sum = 0,b,x=0,counter = 0;
- cin>>a;
- for(int i = 0;i<a;i++)
- {
- cin>>b;
- if(sum==0 && b > 0)
- {
- sum+=b;
- }
- else if(sum>0 && b > 0)
- {
- sum+=b;
- }
- else if(sum>0 && b < 0)
- {
- sum+=b;
- }
- else if(sum == 0 && b < 0)
- {
- counter++;
- }
- }
- cout<<counter <<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement