Does the sequence of including or excluding elements in block via changes in left pointer and right pointer matters. As in question http://codeforces.net/contest/351/problem/D my solution got accepted for left exclusion-> right inclusion-> right exclusion->left inclusion but resulted into wrong answer for left exclusion->left inclusion-> right inclusion-> right exclusion my accepted solution http://codeforces.net/contest/351/submission/31897729 my wrong answer submission-> http://codeforces.net/contest/351/submission/31897757 kindly see this problem as it's strange!!