Comments
On RebrykCodeforces Round #291 (Div. 2), 11 years ago
0

"How many shots from the weapon of what type should R2-D2 make to destroy the sequence of consecutive droids of maximum length?"

You have been destroyed 1, 3 and 4th droid, so your sequence has length 2. In the correct answer, 2, 3 and 4th droid is destroyed, so the sequence has — better — length 3.

Word 'consecutive' is the key.

P. S. Sorry for my english :)

0

Wait... your update is logarithmic? You stop recursion only when low==high (in leaf). So update is too slow in my opinion (You must visit every leaf in (l, r) ).

0

Maybe problem with tree array size or recursion? When i downloaded your code and run it on simply test like this: http://morse.swirski.name/pastes/l6hriqm93kn5wx5gvxckznn0ibd5zvh program crashed in build_tree() function.

When i change tree[] size i don't have this problem. But i'm not sure, cause it was on Windows 7 x64.

P.S. Sorry for my english.

0

Correct segment for ex.: [3->0 1 4 5]