| 4 | #define fo(i,n) for(int i=0;i<n;i++) |
| 5 | |
| 6 | int main() { |
| 7 | //in this question n denotes the number,count denotes the crimes and police denotes the police recruited |
| 8 | int n,count=0,police=0; |
| 9 | cin>>n; |
| 10 | //p[n] is the array of crime cases and recuitments |
| 11 | int p[n]; |
| 12 | fo(i,n){ |
| 13 | cin>>p[i]; |
| 14 | } |
| 15 | //if the i th element of the array is anything except -1 (which denotes crime) that means police recruited is increased from 0 |
| 16 | //else if the crime is increased that means police is assigned and no of policeman free decreases |
| 17 | //otherwise if police count becomes 0 and crimes are reported counts increase which denotes unresolved crimes |
| 18 | fo(i,n){ |
| 19 | if(p[i]!=-1){ |
| 20 | police+=p[i]; |
| 21 | } |
| 22 | else if(p[i]==-1 && police>0){ |
| 23 | police--; |
| 24 | } |
| 25 | else{ |
| 26 | count++; |
| 27 | } |
| 28 | //printing the no of crimes remained |
| 29 | } |
| 30 | cout<<count<<endl; |
| 31 | return 0; |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected