Problem J. Swaps and Inversions
时间限制 1000 ms
内存限制 32 MB
Long long ago, there was an integer sequence a.
Tonyfang think this sequence is messy, so he will count the number of inversions in this sequence. Because he is angry, you will have to pay x yuan for every inversion in the sequence.
You don't want to pay too much, so you can try to play some tricks before he sees this sequence. You can pay y yuan to swap any two adjacent elements.
What is the minimum amount of money you need to spend?
The definition of inversion in this problem is pair $(i,j)$ which $1 \leq i < j \leq n$ and $a_i > a_j$.
输入数据
输出数据
For every test case, a single integer representing minimum money to pay.
样例输入
复制
3 233 666
1 2 3
3 1 666
3 2 1
样例输出
$ Mathjax font initiator $