Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.054 s | 11 KBi |
#2 |
Incorrecto
|
0.057 s | 7 KBi |
#3 |
Incorrecto
|
0.039 s | 7 KBi |
#4 |
Incorrecto
|
0.039 s | 6 KBi |
#5 |
Incorrecto
|
0.056 s | 11 KBi |
#6 |
Incorrecto
|
0.069 s | 33 KBi |
#7 |
Incorrecto
|
0.041 s | 7 KBi |
#8 |
Incorrecto
|
0.066 s | 7 KBi |
#9 |
Incorrecto
|
0.062 s | 7 KBi |
#10 |
Incorrecto
|
0.051 s | 8 KBi |
#11 |
Incorrecto
|
0.063 s | 12 KBi |
#12 |
Incorrecto
|
0.129 s | 20 KBi |
#13 |
Incorrecto
|
0.077 s | 11 KBi |
#14 |
Incorrecto
|
0.201 s | 32 KBi |
#15 |
Incorrecto
|
0.203 s | 34 KBi |
#16 |
Incorrecto
|
0.111 s | 36 KBi |
#17 |
Incorrecto
|
0.154 s | 31 KBi |
#18 |
Incorrecto
|
0.134 s | 18 KBi |
#19 |
Incorrecto
|
0.097 s | 38 KBi |
#20 |
Incorrecto
|
0.064 s | 12 KBi |
const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); rl.on("line", (line) => { const initial = line.split(" ").map(Number); const sorted = quicksort(initial); console.log(arrToString(sorted)); }); function quicksort(arr) { if (arr.length <= 1) { return arr; } const pivot = arr[arr.length - 1]; const lessThanArr = []; const greaterThanArr = []; arr .slice(0, arr.length - 1) .forEach((el) => el < pivot ? lessThanArr.push(el) : greaterThanArr.push(el) ); return [...quicksort(lessThanArr), pivot, ...quicksort(greaterThanArr)]; } function arrToString(arr) { let str = ""; arr.forEach((el) => (str = str + " " + el)); return str.trim(); }