Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 2 KBi |
#2 |
Correcto
|
0.005 s | 72 KBi |
#3 |
Correcto
|
0.004 s | 2 KBi |
#4 |
Correcto
|
0.002 s | 0 KBi |
#5 |
Correcto
|
0.004 s | 0 KBi |
#6 |
Correcto
|
0.004 s | 2 KBi |
#7 |
Correcto
|
0.001 s | 0 KBi |
#8 |
Correcto
|
0.002 s | 0 KBi |
#9 |
Correcto
|
0.005 s | 2 KBi |
#10 |
Correcto
|
0.004 s | 1 KBi |
#11 |
Correcto
|
0.004 s | 0 KBi |
#12 |
Correcto
|
0.002 s | 0 KBi |
#13 |
Correcto
|
0.002 s | 0 KBi |
#14 |
Correcto
|
0.003 s | 0 KBi |
#15 |
Correcto
|
0.008 s | 2 KBi |
#16 |
Correcto
|
0.005 s | 0 KBi |
#17 |
Correcto
|
0.004 s | 0 KBi |
#18 |
Correcto
|
0.004 s | 0 KBi |
#19 |
Correcto
|
0.004 s | 2 KBi |
#20 |
Correcto
|
0.001 s | 0 KBi |
#include <bits/stdc++.h> using namespace std; int partition(int* arr, int l, int r){ int p = arr[r]; int i = l - 1; for(int j=l; j<r; j++){ if(arr[j] < p){ i++; swap(arr[i], arr[j]); } } swap(arr[i+1], arr[r]); return i + 1; } void quickSort(int* arr, int l, int r){ if(l >= r || l < 0) return; int p = partition(arr, l, r); quickSort(arr, l, p-1); quickSort(arr, p+1, r); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // your code goes here int N, i; cin >> N; int arr[N]; for(i=0; i<N; i++){ cin >> arr[i]; } quickSort(arr, 0, N-1); for(i=0; i<N; i++){ cout << arr[i] << " "; } cout << "\n"; return 0; }