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

Envío 6903

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

  • Autor: jarangolp
  • Fecha: 2023-02-28 02:30:09 UTC (Hace alrededor de 1 año)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.04 s 7 KBi
#2
Correcto
0.044 s 7 KBi
#3
Incorrecto
0.05 s 7 KBi
#4
Correcto
0.039 s 7 KBi
#5
Correcto
0.022 s 7 KBi
#6
Correcto
0.023 s 7 KBi
#7
Correcto
0.025 s 7 KBi
#8
Correcto
0.046 s 7 KBi
#9
Correcto
0.053 s 7 KBi
#10
Correcto
0.086 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.024 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.04 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.04 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);
  }

});