Stuff
public cpp v1 · immutable#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); }}