hiho week 39 register

Ended

Participants:2159

Verdict:Accepted
Score:100 / 100
Submitted:2015-04-01 20:59:54

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;
#include <cassert>
void merge(int A[], int *tempArr, const int ibeg, const int imid, const int iend, long &cnt);
void mergeSort(int A[], int *tempArr, const int ibeg, const int iend, long &cnt);
int main() {
    int N;
    if (cin >> N) {
        int *a = new int[N];
        for (int i = 0; i < N; ++i) {
            cin >> a[i];
        }
        int *tempArr = new int[N];
       
        long cnt = 0;
        mergeSort(a, tempArr, 0, N - 1, cnt);
        cout << cnt << endl;
        delete [] tempArr;
        delete [] a;
    }
    return 0;
}
void mergeSort(int A[], int *tempArr, const int ibeg, const int iend, long &cnt) {
    if (ibeg < iend) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX