All pastes #732983 Raw Edit

Stuff

public cpp v1 · immutable
·published 2007-10-11 13:07 UTC
rendered paste body
#include <iostream>bool stack[10001];char s[20001];int main(){  for(int i = 0; i < 10; ++i)  {    int maxDepth = 0, maxCount = 0, count = 0, depth = 0, n;    scanf("%d%s", &n, s);    for(int j = 0; j < n; ++j)     {      if(s[j] == '0' && depth > 0)       {        if(depth > maxDepth)          maxDepth = depth, maxCount = count;        while(stack[depth] && --depth);        stack[depth] = true;        continue;      }      ++count;      stack[++depth] = false;    }    printf("%d\n", maxCount);  }}