Solution of Codeforces Round #244 (Div. 2) - Police Recruits in C.
The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom.” ― Isaac AsimovAgain, I found this problem at http://codeforces.com/contest/427/problem/A.
Here is the solution:-
#include <stdio.h> #include <stdlib.h> int main(){ long police=0,unNoticedCrime=0,n,i; int x; fscanf(stdin,"%ld",&n); if(n>=1 && n<=100000){ for(i=0;i<n;i++){ fscanf(stdin,"%d",&x); switch (x){ case -1: if(police > 0) --police; else ++unNoticedCrime; break; default: police+=x; } } } fprintf(stdout,"%ld",unNoticeCrime); return(0); }
sahi hoo
ReplyDelete