Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.062 s | 8 KBi |
#2 |
Correcto
|
0.048 s | 7 KBi |
#3 |
Correcto
|
0.047 s | 6 KBi |
#4 |
Correcto
|
0.05 s | 6 KBi |
#5 |
Incorrecto
|
0.053 s | 6 KBi |
#6 |
Correcto
|
0.066 s | 6 KBi |
#7 |
Correcto
|
0.062 s | 6 KBi |
#8 |
Correcto
|
0.062 s | 6 KBi |
#9 |
Correcto
|
0.065 s | 6 KBi |
#10 |
Correcto
|
0.051 s | 6 KBi |
#11 |
Correcto
|
0.053 s | 7 KBi |
#12 |
Correcto
|
0.048 s | 6 KBi |
#13 |
Correcto
|
0.066 s | 6 KBi |
#14 |
Correcto
|
0.13 s | 20 KBi |
#15 |
Correcto
|
0.088 s | 19 KBi |
#16 |
Correcto
|
0.136 s | 19 KBi |
#17 |
Correcto
|
0.131 s | 21 KBi |
#18 |
Correcto
|
0.129 s | 20 KBi |
#19 |
Correcto
|
0.121 s | 19 KBi |
#20 |
Correcto
|
0.169 s | 35 KBi |
const readline = require('readline'); const rd = readline.createInterface({ input: process.stdin, output: process.stdout }); rd.question('', n => { rd.question('', numbersInput => { const numbers = numbersInput.split(' ').map(n => Number(n)); let finish = false; let firstRightElementIndex = 1; if (numbers.length > 2) { let totalSum = 0, leftSum = 0; for (let i = 0; i < numbers.length; i++) { totalSum += numbers[i]; } while (firstRightElementIndex < numbers.length && !finish) { leftSum += numbers[firstRightElementIndex-1]; totalSum -= numbers[firstRightElementIndex-1]; finish = (leftSum > 0) && (totalSum < 0); firstRightElementIndex++; } } if (finish) { console.log(firstRightElementIndex-1); } else { console.log('Impossible'); } process.exit(); }); });