report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Inversions - MarisaOJ: Marisa Online Judge

Inversions

Time limit: 1000 ms
Memory limit: 256 MB
You are given a permutation $A$ of length $n$. In one operation, you can select 2 adjacent elements $A_i$ and $A_{i + 1}$ and swap them. Find the minimum number of operations required to sort the permutation in ascending order. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the number of operations required. ### Constraints - $1 \le n \le 10^5$. ### Example Input: ``` 4 2 4 1 3 ``` Output: ``` 3 ```
Introduction to Segment Tree and Binary Indexed Tree
Point update, sum query
Point update, minimum query
Range update, sum query
Range update, minimum query
Apple picking
Non-negative subarray
Inversions
K-query
Divisible by 3
Mushroom harvesting
KSS
D-query
Greatest subarray sum
Copying data
Within 1
Within 2
Ladder update
Racing
One time
Subarray XOR
String sorting
Odd query
Full sequence
Topic
Data structure
Rating 1500
Solution (0) Solution