Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.048 s | 6 KBi |
#2 |
Correcto
|
0.059 s | 6 KBi |
#3 |
Correcto
|
0.053 s | 8 KBi |
#4 |
Correcto
|
0.05 s | 7 KBi |
#5 |
Correcto
|
0.058 s | 6 KBi |
#6 |
Correcto
|
0.054 s | 7 KBi |
#7 |
Correcto
|
0.063 s | 7 KBi |
#8 |
Correcto
|
0.393 s | 15 KBi |
#9 |
Correcto
|
0.766 s | 30 KBi |
#10 |
Correcto
|
0.779 s | 31 KBi |
#11 |
Correcto
|
0.773 s | 30 KBi |
#12 |
Correcto
|
0.776 s | 30 KBi |
#13 |
Correcto
|
0.745 s | 30 KBi |
#14 |
Correcto
|
0.78 s | 30 KBi |
const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.question('', n => { rl.question('', numbersString => { const numbers = numbersString.split(' ').map(n => Number(n)); let sums = [numbers[0]]; for (let i = 1; i < n; i++) { sums[i] = sums[i-1] + numbers[i]; } rl.question('', nQueries => { rl.on('line', queryString => { const query = queryString.split(' ').map(n => Number(n)); const p = query[0]; const q = query[1]; if (p > 0) console.log(sums[q] - sums[p-1]); else console.log(sums[q]) }); }); }); });