Блог пользователя PARTHO_DAS

Автор PARTHO_DAS, история, 4 года назад, По-английски
I am trying to solve [E. Little Elephant and Inversions](https://codeforces.net/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.net/contest/220/submission/96186615)
  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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