MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

String/police.cpp:4–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include<math.h>
3using namespace std;
4int 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected