Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.062 s | 6 KBi |
#2 |
Correcto
|
0.051 s | 7 KBi |
#3 |
Correcto
|
0.049 s | 6 KBi |
#4 |
Correcto
|
0.056 s | 19 KBi |
#5 |
Incorrecto
|
0.05 s | 6 KBi |
#6 |
Correcto
|
0.053 s | 6 KBi |
#7 |
Correcto
|
0.054 s | 6 KBi |
#8 |
Correcto
|
0.058 s | 14 KBi |
#9 |
Correcto
|
0.059 s | 6 KBi |
#10 |
Correcto
|
0.063 s | 6 KBi |
#11 |
Correcto
|
0.064 s | 12 KBi |
#12 |
Correcto
|
0.049 s | 6 KBi |
#13 |
Correcto
|
0.065 s | 6 KBi |
#14 |
Correcto
|
0.36 s | 20 KBi |
#15 |
Tiempo límite excedido
|
1.574 s | 19 KBi |
#16 |
Tiempo límite excedido
|
1.532 s | 26 KBi |
#17 |
Tiempo límite excedido
|
1.519 s | 21 KBi |
#18 |
Correcto
|
0.122 s | 20 KBi |
#19 |
Tiempo límite excedido
|
1.554 s | 22 KBi |
#20 |
Tiempo límite excedido
|
1.577 s | 37 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) { while (firstRightElementIndex < numbers.length && !finish) { 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++; } } if (finish) { console.log(firstRightElementIndex-1); } else { console.log('Impossible'); } process.exit(); }); });