Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.001 s | 0 KBi |
#3 |
Correcto
|
0.004 s | 0 KBi |
#4 |
Correcto
|
0.003 s | 0 KBi |
#5 |
Correcto
|
0.004 s | 0 KBi |
#6 |
Correcto
|
0.005 s | 2 KBi |
#7 |
Correcto
|
0.019 s | 1 KBi |
#8 |
Correcto
|
0.021 s | 1 KBi |
#9 |
Correcto
|
0.018 s | 1 KBi |
#10 |
Correcto
|
0.022 s | 1 KBi |
#11 |
Correcto
|
0.081 s | 2 KBi |
#12 |
Correcto
|
0.061 s | 4 KBi |
#13 |
Correcto
|
0.057 s | 2 KBi |
#14 |
Correcto
|
0.055 s | 4 KBi |
#15 |
Correcto
|
0.06 s | 2 KBi |
#16 |
Correcto
|
0.078 s | 2 KBi |
#17 |
Correcto
|
0.09 s | 2 KBi |
#18 |
Correcto
|
0.017 s | 2 KBi |
#19 |
Correcto
|
0.049 s | 2 KBi |
#20 |
Correcto
|
0.025 s | 1 KBi |
#21 |
Correcto
|
0.06 s | 2 KBi |
#22 |
Correcto
|
0.063 s | 2 KBi |
#23 |
Correcto
|
0.055 s | 2 KBi |
#24 |
Correcto
|
0.051 s | 2 KBi |
#25 |
Correcto
|
0.052 s | 2 KBi |
#26 |
Correcto
|
0.033 s | 2 KBi |
#27 |
Correcto
|
0.055 s | 2 KBi |
// // Created by danie on 11/14/2021. // #include <iostream> #include <vector> #define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; void merge(vector<int> &list, int from, int half, int to){ int firstHalf = half; int firstFrom = from; int mergedSize = (to - from) + 1; int mergedArray[mergedSize]; for (int i = 0; i < mergedSize; i++){ if((from < firstHalf + 1 && list[from] < list[half + 1]) || (half == to)){ mergedArray[i] = list[from]; from ++; } else{ mergedArray[i] = list[half + 1]; half ++; } } for (int i = 0; i < mergedSize; i++){ list[firstFrom + i] = mergedArray[i]; } } void __merge_sort(vector<int> &cards, int from, int to){ if (from < to){ int half = (to + from) / 2; __merge_sort(cards, from, half); __merge_sort(cards, half + 1, to); merge(cards, from, half, to); } } void merge_sort(vector<int> &cards){ __merge_sort(cards, 0, cards.size() - 1); } //void test_merge_sort(){ // vector<int> cards ={5,2,4,7,1,3,2,6}; // merge_sort(cards); // for(int card : cards) cout<<card<<' '; //} int main(){ fast_io // vector<int> cards = {0,1,43653,7437,3473,23,5,352,235}; // radix_sort_non_negatives(cards); vector<int> cards; int n, in; cin>>n; for (int i = 0; i < n; i++){ cin>>in; cards.push_back(in); } merge_sort(cards); for(int num: cards) cout<<num<<' '; }