PARTHO_DAS's blog

By PARTHO_DAS, history, 4 years ago, In English
I am trying to solve [E. Little Elephant and Inversions](https://mirror.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://mirror.codeforces.com/contest/220/submission/96186615)
  • Vote: I like it
  • +2
  • Vote: I do not like it

»
4 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

You have to pick the union of $$$[1, l]$$$ and $$$[r, n]$$$, not the subarray $$$[l, r]$$$.