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

Envío 6018

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

  • Autor: jarangolp
  • Fecha: 2022-05-02 21:57:57 UTC (Hace casi 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.021 s 6 KBi
#2
Correcto
0.071 s 6 KBi
#3
Correcto
0.076 s 23 KBi
#4
Correcto
0.032 s 7 KBi
#5
Correcto
0.026 s 7 KBi
#6
Correcto
0.056 s 7 KBi
#7
Correcto
0.056 s 7 KBi
#8
Correcto
0.021 s 7 KBi
#9
Correcto
0.021 s 7 KBi
#10
Correcto
0.135 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.079 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.026 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.026 s 8 KBi
Puntos totales: 77 / 100

Código

process.stdin.on('data', input => {
  const dataArray = input.toString().split('\n');
  const N = 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);
  }

});