Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.007 s | 7 KBi |
#2 |
Correcto
|
0.006 s | 1 KBi |
#3 |
Correcto
|
0.007 s | 1 KBi |
#4 |
Correcto
|
0.007 s | 21 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.009 s | 4 KBi |
#7 |
Correcto
|
0.15 s | 2 KBi |
#8 |
Correcto
|
0.16 s | 2 KBi |
#9 |
Correcto
|
0.117 s | 2 KBi |
#10 |
Correcto
|
0.134 s | 3 KBi |
#11 |
Correcto
|
0.139 s | 3 KBi |
#12 |
Correcto
|
0.144 s | 3 KBi |
#13 |
Correcto
|
0.123 s | 3 KBi |
#14 |
Correcto
|
0.117 s | 3 KBi |
#15 |
Correcto
|
0.119 s | 3 KBi |
#16 |
Correcto
|
0.154 s | 3 KBi |
#17 |
Correcto
|
0.149 s | 3 KBi |
#18 |
Correcto
|
0.126 s | 2 KBi |
#19 |
Correcto
|
0.124 s | 3 KBi |
#20 |
Correcto
|
0.105 s | 2 KBi |
#21 |
Correcto
|
0.12 s | 3 KBi |
#22 |
Correcto
|
0.118 s | 3 KBi |
#23 |
Correcto
|
0.128 s | 2 KBi |
#24 |
Correcto
|
0.131 s | 3 KBi |
#25 |
Correcto
|
0.129 s | 3 KBi |
#26 |
Correcto
|
0.116 s | 3 KBi |
#27 |
Correcto
|
0.127 s | 2 KBi |
#include<iostream> #include<vector> using namespace std; void merge(vector<int> &A,int p, int q, int r){ int n1 = q-p+1; int n2 = r-q; vector<int>L(n1,0); vector<int>M(n2,0); for(int i=0;i<n1;i++){ L[i] = A[p+i]; } for(int j=0;j<n2;j++){ M[j] = A[q+1+j]; } int i=0,j=0,k=p; while(i<n1 && j<n2){ if(L[i]<=M[j]){ A[k] = L[i]; i++; } else{ A[k]= M[j]; j++; } k++; } while(i<n1){ A[k]=L[i]; i++; k++; } while(j<n2){ A[k]=M[j]; j++; k++; } } void mergeSort(vector<int> &A, int p, int r){ if(p<r){ int m = p+(r-p)/2; mergeSort(A,p,m); mergeSort(A,m+1,r); merge(A,p,m,r); } } int main(){ int n; cin>>n; vector<int> vals(n); for(auto &val: vals){ cin>>val; } mergeSort(vals,0,vals.size()-1); for(int val:vals){ cout<<val<<" "; } cout<<"\n"; return 0; }