Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 19 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.077 s | 2 KBi |
#8 |
Correcto
|
0.086 s | 2 KBi |
#9 |
Correcto
|
0.083 s | 2 KBi |
#10 |
Correcto
|
0.09 s | 2 KBi |
#11 |
Correcto
|
0.109 s | 3 KBi |
#12 |
Correcto
|
0.109 s | 3 KBi |
#13 |
Correcto
|
0.095 s | 2 KBi |
#14 |
Correcto
|
0.094 s | 2 KBi |
#15 |
Correcto
|
0.094 s | 2 KBi |
#16 |
Correcto
|
0.127 s | 3 KBi |
#17 |
Correcto
|
0.12 s | 3 KBi |
#18 |
Correcto
|
0.089 s | 2 KBi |
#19 |
Correcto
|
0.094 s | 2 KBi |
#20 |
Correcto
|
0.087 s | 2 KBi |
#21 |
Correcto
|
0.1 s | 2 KBi |
#22 |
Correcto
|
0.087 s | 2 KBi |
#23 |
Correcto
|
0.091 s | 2 KBi |
#24 |
Correcto
|
0.093 s | 2 KBi |
#25 |
Correcto
|
0.098 s | 2 KBi |
#26 |
Correcto
|
0.097 s | 2 KBi |
#27 |
Correcto
|
0.094 s | 2 KBi |
#include <iostream> #include <vector> using namespace std; void merge(vector<int> &nums, int left, int right) { int mid = left + (right - left) / 2; int n1 = mid - left + 1; int n2 = right - mid; vector<int> leftE(n1); vector<int> rightE(n2); for (int i = 0; i < n1; i++) leftE[i] = nums[left + i]; for (int j = 0; j < n2; j++) rightE[j] = nums[mid + 1 + j]; int i = 0; int j = 0; int k = left; while (i < n1 && j < n2) { if (leftE[i] <= rightE[j]) { nums[k] = leftE[i]; i++; } else { nums[k] = rightE[j]; j++; } k++; } while (i < n1) { nums[k] = leftE[i]; i++; k++; } while (j < n2) { nums[k] = rightE[j]; j++; k++; } } void sort(vector<int> &nums, int left, int right) { if (left >= right) { return; } int mid = left + (right - left) / 2; sort(nums, left, mid); sort(nums, mid + 1, right); merge(nums, left, right); } int main() { int n; cin >> n; vector<int> nums(n); for (int i = 0; i < n; ++i) { cin >> nums[i]; } sort(nums, 0, n - 1); for (auto num : nums) { cout << num << " "; } cout << endl; return 0; }