█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 6019

Problema 0x9b - Máximo elemento en un subarreglo pequeño

  • Autor: jarangolp
  • Fecha: 2022-05-02 21:59:21 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.019 s 6 KBi
#2
Correcto
0.023 s 6 KBi
#3
Incorrecto
0.02 s 6 KBi
#4
Correcto
0.025 s 7 KBi
#5
Correcto
0.029 s 7 KBi
#6
Correcto
0.056 s 8 KBi
#7
Correcto
0.06 s 7 KBi
#8
Correcto
0.02 s 7 KBi
#9
Correcto
0.029 s 7 KBi
#10
Correcto
0.035 s 8 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
/box/script.js:8
  const numbers = dataArray[1].split(' ').map(n => Number(n));
                               ^

TypeError: Cannot read property 'split' of undefined
    at ReadStream.<anonymous> (/box/script.js:8:32)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
    at internal/fs/streams.js:191:12
    at FSReqCallback.wrapper [as oncomplete] (fs.js:470:5)
0.032 s 8 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
/box/script.js:8
  const numbers = dataArray[1].split(' ').map(n => Number(n));
                               ^

TypeError: Cannot read property 'split' of undefined
    at ReadStream.<anonymous> (/box/script.js:8:32)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
    at internal/fs/streams.js:191:12
    at FSReqCallback.wrapper [as oncomplete] (fs.js:470:5)
0.035 s 8 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
/box/script.js:8
  const numbers = dataArray[1].split(' ').map(n => Number(n));
                               ^

TypeError: Cannot read property 'split' of undefined
    at ReadStream.<anonymous> (/box/script.js:8:32)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
    at internal/fs/streams.js:191:12
    at FSReqCallback.wrapper [as oncomplete] (fs.js:470:5)
0.028 s 8 KBi
Puntos totales: 70 / 100

Código

process.stdin.on('data', input => {
  const dataArray = input.toString().split('\n');
  const N = Number(dataArray[0]);
  if (N === 1) {
    console.log(0);
    return;
  }
  const numbers = dataArray[1].split(' ').map(n => Number(n));
  const q = Number(dataArray[2]);
  for (let i = 0; i < q; i++) {
    const [L,R] = dataArray[i+3].split(' ').map(n => Number(n));
    const array = numbers.slice(L,R+1);
    const max = Math.max(...array);
   console.log(array.indexOf(max)+L);
  }

});