Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.002 s | 0 KBi |
#2 |
Correcto
|
0.007 s | 2 KBi |
#3 |
Correcto
|
0.001 s | 0 KBi |
#4 |
Correcto
|
0.002 s | 0 KBi |
#5 |
Correcto
|
0.002 s | 0 KBi |
#6 |
Correcto
|
0.002 s | 0 KBi |
#7 |
Correcto
|
0.015 s | 1 KBi |
#8 |
Correcto
|
0.019 s | 1 KBi |
#9 |
Correcto
|
0.014 s | 1 KBi |
#10 |
Correcto
|
0.029 s | 3 KBi |
#11 |
Correcto
|
0.023 s | 2 KBi |
#12 |
Correcto
|
0.031 s | 4 KBi |
#13 |
Correcto
|
0.015 s | 2 KBi |
#14 |
Correcto
|
0.016 s | 2 KBi |
#15 |
Correcto
|
0.016 s | 2 KBi |
#16 |
Correcto
|
0.025 s | 2 KBi |
#17 |
Correcto
|
0.059 s | 6 KBi |
#18 |
Correcto
|
0.024 s | 3 KBi |
#19 |
Correcto
|
0.03 s | 3 KBi |
#20 |
Correcto
|
0.015 s | 1 KBi |
#21 |
Correcto
|
0.016 s | 2 KBi |
#22 |
Correcto
|
0.022 s | 3 KBi |
#23 |
Correcto
|
0.023 s | 3 KBi |
#24 |
Correcto
|
0.017 s | 2 KBi |
#25 |
Correcto
|
0.026 s | 3 KBi |
#26 |
Correcto
|
0.022 s | 2 KBi |
#27 |
Correcto
|
0.028 s | 3 KBi |
#include <bits/stdc++.h> using namespace std; void merge(int *arr, int l, int m, int r){ int i, j, k; int n1 = m - l + 1; int n2 = r - m; int L[n1], R[n2]; for (i = 0; i < n1; i++) L[i] = arr[l + i]; for (j = 0; j < n2; j++) R[j] = arr[m + 1 + j]; i = 0; // Initial index of first subarray j = 0; // Initial index of second subarray k = l; // Initial index of merged subarray while (i < n1 && j < n2) { if (L[i] <= R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } k++; } while (i < n1) { arr[k] = L[i]; i++; k++; } while (j < n2) { arr[k] = R[j]; j++; k++; } } void mergeSort(int *arr, int l, int r){ if(l>=r || l<0) return; int m = l + (r-l)/2; mergeSort(arr, l, m); mergeSort(arr, m+1, r); merge(arr, l, m, r); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // your code goes here int N, i; cin >> N; int arr[N]; for(i=0; i<N; i++) cin >> arr[i]; mergeSort(arr, 0, N-1); for(i=0; i<N; i++) cout << arr[i] << " "; cout << "\n"; return 0; }