Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.002 s | 0 KBi |
#2 |
Correcto
|
0.002 s | 0 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.022 s | 1 KBi |
#8 |
Correcto
|
0.022 s | 1 KBi |
#9 |
Correcto
|
0.02 s | 1 KBi |
#10 |
Correcto
|
0.023 s | 1 KBi |
#11 |
Correcto
|
0.039 s | 2 KBi |
#12 |
Correcto
|
0.089 s | 36 KBi |
#13 |
Correcto
|
0.027 s | 2 KBi |
#14 |
Correcto
|
0.026 s | 2 KBi |
#15 |
Correcto
|
0.026 s | 2 KBi |
#16 |
Correcto
|
0.048 s | 2 KBi |
#17 |
Correcto
|
0.042 s | 2 KBi |
#18 |
Correcto
|
0.027 s | 1 KBi |
#19 |
Correcto
|
0.025 s | 2 KBi |
#20 |
Correcto
|
0.022 s | 1 KBi |
#21 |
Correcto
|
0.026 s | 2 KBi |
#22 |
Correcto
|
0.027 s | 2 KBi |
#23 |
Correcto
|
0.026 s | 2 KBi |
#24 |
Correcto
|
0.044 s | 3 KBi |
#25 |
Correcto
|
0.03 s | 2 KBi |
#26 |
Correcto
|
0.043 s | 18 KBi |
#27 |
Correcto
|
0.03 s | 2 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 + 1], R[n2 + 1]; 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]; L[n1] = INT_MAX; R[n2] = INT_MAX; int i = 0, j = 0; for (int k = p; k <= r; k++) { if(L[i] <= R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } } } 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; }