Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.003 s | 0 KBi |
#2 |
Correcto
|
0.004 s | 1 KBi |
#3 |
Correcto
|
0.006 s | 2 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.004 s | 1 KBi |
#6 |
Correcto
|
0.006 s | 2 KBi |
#7 |
Correcto
|
0.096 s | 2 KBi |
#8 |
Correcto
|
0.105 s | 2 KBi |
#9 |
Correcto
|
0.101 s | 2 KBi |
#10 |
Correcto
|
0.151 s | 2 KBi |
#11 |
Correcto
|
0.131 s | 3 KBi |
#12 |
Correcto
|
0.129 s | 3 KBi |
#13 |
Correcto
|
0.109 s | 2 KBi |
#14 |
Correcto
|
0.125 s | 3 KBi |
#15 |
Correcto
|
0.129 s | 2 KBi |
#16 |
Correcto
|
0.179 s | 3 KBi |
#17 |
Correcto
|
0.125 s | 2 KBi |
#18 |
Correcto
|
0.104 s | 1 KBi |
#19 |
Correcto
|
0.132 s | 3 KBi |
#20 |
Correcto
|
0.1 s | 2 KBi |
#21 |
Correcto
|
0.134 s | 2 KBi |
#22 |
Correcto
|
0.116 s | 2 KBi |
#23 |
Correcto
|
0.134 s | 2 KBi |
#24 |
Correcto
|
0.126 s | 2 KBi |
#25 |
Correcto
|
0.116 s | 3 KBi |
#26 |
Correcto
|
0.126 s | 2 KBi |
#27 |
Correcto
|
0.109 s | 1 KBi |
#include <bits/stdc++.h> using namespace std; void merge(vector<int> &arr, int l_, int m, int r){ vector<int> left(m-l_+1), rigth(r-m); for(int i=l_, j=0; i<=m; ++i, ++j) left[j] = arr[i]; for(int i=m+1, j=0; i<=r; ++i, ++j) rigth[j] = arr[i]; int i = 0, j = 0, l =l_; while(i < m-l_+1 && j < r-m){ if(left[i] <= rigth[j]) arr[l++] = left[i++]; else arr[l++] = rigth[j++]; } while(i < m-l_+1) arr[l++] = left[i++]; while(j < r-m) arr[l++] = rigth[j++]; } void mergeSort(vector<int> &arr, int l, int r){ if(l >= r) return; else{ int m = l + (r - l)/2; mergeSort(arr, l, m); mergeSort(arr, m+1, r); merge(arr, l, m, r); } } int main(){ int n; cin >> n; vector<int> arr(n); for(int &i: arr) cin >> i; mergeSort(arr, 0, n-1); for(int i: arr) cout << i << " "; return 0; }