Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.057 s | 7 KBi |
#2 |
Correcto
|
0.065 s | 6 KBi |
#3 |
Correcto
|
0.053 s | 6 KBi |
#4 |
Correcto
|
0.066 s | 6 KBi |
#5 |
Incorrecto
|
0.051 s | 6 KBi |
#6 |
Correcto
|
0.049 s | 6 KBi |
#7 |
Correcto
|
0.075 s | 6 KBi |
#8 |
Correcto
|
0.064 s | 7 KBi |
#9 |
Correcto
|
0.059 s | 6 KBi |
#10 |
Correcto
|
0.049 s | 7 KBi |
#11 |
Correcto
|
0.056 s | 8 KBi |
#12 |
Correcto
|
0.046 s | 6 KBi |
#13 |
Correcto
|
0.062 s | 6 KBi |
#14 |
Correcto
|
0.141 s | 20 KBi |
#15 |
Correcto
|
0.119 s | 21 KBi |
#16 |
Correcto
|
0.153 s | 19 KBi |
#17 |
Correcto
|
0.132 s | 20 KBi |
#18 |
Correcto
|
0.122 s | 22 KBi |
#19 |
Correcto
|
0.134 s | 19 KBi |
#20 |
Correcto
|
0.234 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 rightSum = 0, leftSum = 0; for (let i = 0; i < firstRightElementIndex; i++) { leftSum += numbers[i]; } for (let i = firstRightElementIndex; i < numbers.length; i++) { rightSum += numbers[i]; } finish = (leftSum > 0) && (rightSum < 0); firstRightElementIndex++; while (firstRightElementIndex < numbers.length && !finish) { leftSum += numbers[firstRightElementIndex-1]; rightSum -= numbers[firstRightElementIndex-1]; finish = (leftSum > 0) && (rightSum < 0); firstRightElementIndex++; } } if (finish) { console.log(firstRightElementIndex-1); } else { console.log('Impossible'); } process.exit(); }); });