INFINITE INVERSIONS

Revision en1, by vsanjay_nitdgp, 2015-10-13 21:27:38

Recently,i was solving the following problem: http://mirror.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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English vsanjay_nitdgp 2015-10-13 21:27:38 570 Initial revision (published)