Time Limit: 7000MS | Memory Limit: 65536K | |
Total Submissions: 35024 | Accepted: 12608 |
Description
9 1 0 5 4 ,
Ultra-QuickSort produces the output
0 1 4 5 9 .
Your task is to determine how many swap operations Ultra-QuickSort needs to perform in order to sort a given input sequence.
Input
Output
Sample Input
5
9 1 0 5 4
3
1 2 3
0
Sample Output
6
0
Source
#include <iostream>
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct node bool cmp(node a,node b) int ar[550000],tree[550000],n; int lowbit(int x) void update(int x,int v) int getsum(int x) int main() |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )