Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.067 s | 7 KBi |
#2 |
Correcto
|
0.057 s | 7 KBi |
#3 |
Correcto
|
0.066 s | 32 KBi |
#4 |
Correcto
|
0.074 s | 32 KBi |
#5 |
Correcto
|
0.052 s | 7 KBi |
#6 |
Correcto
|
0.064 s | 11 KBi |
#7 |
Correcto
|
0.074 s | 33 KBi |
#8 |
Correcto
|
1.447 s | 18 KBi |
#9 |
Tiempo límite excedido
|
1.546 s | 16 KBi |
#10 |
Tiempo límite excedido
|
1.518 s | 17 KBi |
#11 |
Tiempo límite excedido
|
1.505 s | 19 KBi |
#12 |
Tiempo límite excedido
|
1.6 s | 18 KBi |
#13 |
Correcto
|
0.709 s | 38 KBi |
#14 |
Tiempo límite excedido
|
1.566 s | 19 KBi |
let readline = require("readline"); let lineNumber = 0; let listNumber = []; let listLengthInput; let listLenghtQuery; let listQueryResults = []; let slice; process.stdin.setEncoding("utf8"); let stdin = readline.createInterface({ input: process.stdin, terminal: false, }); stdin.on("line", readLine); const reducer = (accumulator, currentValue) => accumulator + currentValue; function readLine(line) { if (lineNumber == 0) { listLengthInput = parseInt(line); lineNumber++; } else if (lineNumber == 1) { listNumber = line .toString() .split(/\s+/) .map((item) => parseInt(item)); lineNumber++; } else if (lineNumber == 2) { listLenghtQuery = parseInt(line); lineNumber++; } else if (lineNumber > 2) { slice = line .toString() .split(/\s+/) .map((item) => parseInt(item)); let sliceSum = listNumber.slice(slice[0], slice[1] + 1).reduce(reducer, 0); listQueryResults.push(sliceSum); if (listQueryResults.length === listLenghtQuery) { listQueryResults.map((queryResult) => console.log(queryResult)); } } }