Bubble sort
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Determine how many exchange operations are done in bubble sort algorithm to sort the elements of array in ascending order.
Input
The first line contains the number of elements n (1 ≤ n ≤ 1000) in array. The second line contains the array itself. It is guaranteed that all array elements are different and do not exceed 10^9
by absolute value.
Output
Print the number of swaps in bubble sort.
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 14K
Acceptance rate 46%