Medeali's blog

By Medeali, history, 2 years ago, In English

i am trying to solve this problem https://mirror.codeforces.com/edu/course/2/lesson/4/2/practice/contest/273278/problem/B this is my code https://ideone.com/T1U9z5 i got WA on test 16 but i cannot spot the mistake i made

  • Vote: I like it
  • -5
  • Vote: I do not like it

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Damn, you are green and solving segment tree...

If you know russian you can watch pashka's tutorial on that problem, and find mistake by yourself

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

The problem is on line 89. When you go in the right subtree, you need to subtract the number of $$$1$$$ in the left subtree.

Something like this:

k-=sums[search*2];
search=search*2+1;