vsanjay_nitdgp's blog

By vsanjay_nitdgp, history, 9 years ago, In English

Recently,i was solving the following problem: http://codeforces.com/problemset/problem/540/E

the following is the solution i am trying to understand: http://ideone.com/cKjRNr

In the last loop of solution there are two terms,1 is to find difference of initial and final position of that element.

what about second term.according to editorial ,second term is to delete the inversions that were already counted.

so,could any one help how did we get "num[i]-i" as our second term,,whats the proof behind it..

pls help,thanks in advance.

  • Vote: I like it
  • 0
  • Vote: I do not like it