hiho week 39 register

Ended

Participants:2159

Verdict:Wrong Answer
Score:80 / 100
Submitted:2015-04-03 13:26:53

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using namespace std;
int InversePairsCore(int *data,int *copy,int start,int end)
{
    if (start == end)
    {
        copy[start] = data[start];
        return 0;
    }
    int length = (end - start)/2;
    int left_c = InversePairsCore(copy,data,start,start+length);
    int right_c = InversePairsCore(copy,data,start+length+1,end);
    int i = start + length;
    int j = end;
    int index_copy = end;
    int count = 0;
    
    while (i>=start && j>=start+length+1)
    {
        if (data[i] > data[j])
        {
            copy[index_copy--] = data[i--];
            count += j - (start+length);
        }
        else
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX