codechef June 2014 long challenge - CHEFZOT - chef and subarray editorial: http://discuss.codechef.com/questions/44792/chefzot-editorial
codechef June 2014 long challenge - CHEFZOT - chef and subarray solution:
#include <iostream> #include <cstdio> #include <climits> using namespace std; int main() { int n, a, cnt=0, max=INT_MIN; scanf("%d", &n); while(n--) { scanf("%d", &a); if(a!=0) cnt++; if(cnt>max) max=cnt; if(a==0) cnt=0; } printf("%d", max); return 0; }
No comments:
Post a Comment