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

Envío 5581

Problema 0xd6 - Camino más corto de la Tortuga en un arreglo circular

  • Autor: pablopvsky
  • Fecha: 2022-01-10 23:55:32 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.02 s 7 KBi
#2
Incorrecto
0.064 s 7 KBi
#3
Incorrecto
0.027 s 7 KBi
#4
Incorrecto
0.073 s 6 KBi
#5
Incorrecto
0.054 s 6 KBi
#6
Incorrecto
0.025 s 6 KBi
#7
Incorrecto
0.029 s 6 KBi
#8
Incorrecto
0.025 s 7 KBi
#9
Incorrecto
0.083 s 17 KBi
#10
Incorrecto
0.068 s 6 KBi
#11
Incorrecto
0.065 s 8 KBi
#12
Incorrecto
0.079 s 9 KBi
#13
Incorrecto
0.024 s 7 KBi
#14
Incorrecto
0.027 s 7 KBi
#15
Incorrecto
0.047 s 7 KBi
#16
Incorrecto
0.055 s 6 KBi
#17
Incorrecto
0.047 s 6 KBi
#18
Incorrecto
0.028 s 6 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.282 s 125 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.467 s 125 KBi
#21
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.635 s 125 KBi
#22
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.294 s 125 KBi
#23
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.72 s 125 KBi
#24
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.286 s 125 KBi
#25
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.614 s 125 KBi
#26
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.447 s 125 KBi
#27
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.805 s 125 KBi
#28
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.822 s 125 KBi
#29
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.468 s 125 KBi
#30
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.683 s 125 KBi
#31
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.651 s 125 KBi
#32
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.753 s 125 KBi
#33
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.645 s 125 KBi
#34
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.635 s 125 KBi
#35
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.628 s 125 KBi
#36
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/node-12.14.0/bin/node script.js
0.773 s 125 KBi
Puntos totales: 0 / 100

Código

let readline = require("readline");

let rightWay;
let leftWay;

process.stdin.setEncoding("utf8");
let stdin = readline.createInterface({
  input: process.stdin,
  terminal: false,
});

stdin.on("line", readLine);

function readLine(line) {
  let input = line.split(" ");
  let circleLength = Number(input[0]);
  let circleCells = new Array(circleLength).fill(0);
  let position = Number(input[1]);
  let goal = Number(input[2]);

  if (position === goal) {
    console.log(0);
  }

  if (position < goal) {
    console.log("first method");
    rightWay = circleCells.slice(position + 1, goal + 1).length;
    leftWay =
      circleCells.slice(0, position).length +
      circleCells.slice(goal, circleLength).length;
  } else {
    console.log("second method");
    leftWay = circleCells.slice(goal, position).length;
    rightWay =
      circleCells.slice(0, goal).length +
      circleCells.slice(position, circleLength).length -
      1;
  }

  if (rightWay < leftWay) {
    console.log(rightWay);
  } else {
    console.log(leftWay);
  }
}