Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.002 s | 0 KBi |
#2 |
Correcto
|
0.002 s | 0 KBi |
#3 |
Correcto
|
0.002 s | 0 KBi |
#4 |
Correcto
|
0.002 s | 0 KBi |
#5 |
Correcto
|
0.003 s | 0 KBi |
#6 |
Correcto
|
0.001 s | 0 KBi |
#7 |
Correcto
|
0.021 s | 1 KBi |
#8 |
Correcto
|
0.025 s | 1 KBi |
#9 |
Correcto
|
0.023 s | 1 KBi |
#10 |
Correcto
|
0.025 s | 1 KBi |
#11 |
Correcto
|
0.038 s | 2 KBi |
#12 |
Correcto
|
0.059 s | 3 KBi |
#13 |
Correcto
|
0.042 s | 3 KBi |
#14 |
Correcto
|
0.034 s | 2 KBi |
#15 |
Correcto
|
0.067 s | 2 KBi |
#16 |
Correcto
|
0.041 s | 2 KBi |
#17 |
Correcto
|
0.041 s | 2 KBi |
#18 |
Correcto
|
0.028 s | 2 KBi |
#19 |
Correcto
|
0.038 s | 2 KBi |
#20 |
Correcto
|
0.021 s | 1 KBi |
#21 |
Correcto
|
0.034 s | 2 KBi |
#22 |
Correcto
|
0.037 s | 1 KBi |
#23 |
Correcto
|
0.027 s | 2 KBi |
#24 |
Correcto
|
0.028 s | 2 KBi |
#25 |
Correcto
|
0.028 s | 2 KBi |
#26 |
Correcto
|
0.031 s | 2 KBi |
#27 |
Correcto
|
0.06 s | 3 KBi |
#include <bits/stdc++.h> using namespace std; void printArray(int arr[], int size) { for(int i = 0; i < size; i++) cout<<arr[i]<<" "; cout<<endl; } void merge(int arr[], int p, int q, int r) { int n1 = q - p + 1; int n2 = r - q; int L[n1], R[n2]; for (int i = 0; i < n1; i++) L[i] = arr[p + i]; for (int j = 0; j < n2; j++) R[j] = arr[q + 1 + j]; int i = 0, j = 0, k = p; 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 p, int r) { if(p < r) { int q = (p + r) / 2; mergeSort(arr, p, q); mergeSort(arr, q + 1, r); merge(arr, p, q, r); } } int main() { int n; cin>>n; int arr[n]; for(int i = 0; i < n; i++) { cin>>arr[i]; } mergeSort(arr, 0, n - 1); printArray(arr, n); return 0; }