Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.057 s | 7 KBi |
#2 |
Incorrecto
|
0.082 s | 9 KBi |
#3 |
Incorrecto
|
0.067 s | 7 KBi |
#4 |
Incorrecto
|
0.065 s | 7 KBi |
#5 |
Incorrecto
|
0.07 s | 7 KBi |
#6 |
Incorrecto
|
0.075 s | 7 KBi |
#7 |
Incorrecto
|
0.073 s | 7 KBi |
#8 |
Incorrecto
|
0.341 s | 18 KBi |
#9 |
Tiempo límite excedido
|
1.018 s | 35 KBi |
#10 |
Incorrecto
|
0.975 s | 31 KBi |
#11 |
Incorrecto
|
0.962 s | 31 KBi |
#12 |
Tiempo límite excedido
|
1.071 s | 32 KBi |
#13 |
Tiempo límite excedido
|
1.078 s | 30 KBi |
#14 |
Incorrecto
|
0.978 s | 35 KBi |
const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); let lineCounter = 0; let subTotalsArray; function sumSubTotals(initialArray) { let totalsArray = [] let currentSum = 0; for(let i = 0; i < initialArray.length; i++) { currentSum = currentSum + i totalsArray.push(currentSum) } return totalsArray } function sumSubArray(fromIndex, toIndex){ const fromTotal = subTotalsArray[fromIndex - 1]; const toTotal = subTotalsArray[toIndex] return toTotal - fromTotal } rl.on("line", (line) => { lineCounter++; if (lineCounter === 2) { // Run the initial algorithm const initialArray = line.split(" ").map(Number); subTotalsArray = sumSubTotals(initialArray) } if (lineCounter > 3) { // these are the inputs Q & P const [Q, P] = line.split(" ").map(Number); console.log(sumSubArray(Q, P)) } })