Can some one explain the third test case of the 220E Problem. I am not able to understand the Problem.

Revision en1, by PARTHO_DAS, 2020-10-22 22:00:19
I am trying to solve [E. Little Elephant and Inversions](https://codeforces.com/contest/220/problem/E)
But in the third test case : 
7 3
1 7 6 4 9 5 3
The expected output is: 6
But I can't understand how it's possible, in my logic I find the answer is: 15

7 3
1 7 6 4 9 5 3
-------------
0 1 2 3 4 5 6 // i
I find : 
5 3       || l = 5, r = 6
9 5 3     || l = 4, r = 6
9 5       || l = 4, r = 5
4 9 5     || l = 3, r = 5
4 9       || l = 3, r = 4
6 4 9 5   || l = 2, r = 5
6 4 9     || l = 2, r = 4
6 4       || l = 2, r = 3
7 6 4 9   || l = 1, r = 4
7 6 4     || l = 1, 4 = 3
7 6       || l = 1, r = 2
1 7 6 4 9 || l = 0, r = 4
1 7 6 4   || l = 0, r = 3
1 7 6     || l = 0, r = 2
1 7       || l = 0, r = 1
----------------------------
15 unique l and r, where inversions count is less than or equal to 3.

[My submission](https://codeforces.com/contest/220/submission/96186615)
Tags #segment tree, #debug

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English PARTHO_DAS 2020-10-22 22:00:19 1029 Initial revision (published)