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

Envío 4482

Problema 0x62 - Contar elementos mayores a X en un arreglo pequeño

  • Autor: pablopvsky
  • Fecha: 2021-07-03 21:26:45 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.04 s 7 KBi
#2
Incorrecto
0.059 s 7 KBi
#3
Incorrecto
0.062 s 7 KBi
#4
Incorrecto
0.054 s 7 KBi
#5
Correcto
0.04 s 7 KBi
#6
Incorrecto
0.057 s 7 KBi
#7
Incorrecto
0.063 s 8 KBi
#8
Correcto
0.071 s 8 KBi
#9
Incorrecto
0.114 s 8 KBi
#10
Correcto
0.072 s 8 KBi
Puntos totales: 40 / 100

Código

let readline = require("readline");

let lineNumber = 0;
let listLengthInput;
let listNumber;
let listLenghtQuery;
let listQuery = [];
let listVerify = [];

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

stdin.on("line", readLine);

function readLine(line) {
  if (lineNumber == 0) {
    listLengthInput = parseInt(line);
    lineNumber++;
  } else if (lineNumber == 1) {
    listNumber = line.toString().split(/\s+/);
    lineNumber++;
  } else if (lineNumber == 2) {
    listLenghtQuery = parseInt(line);
    listVerify = new Array(listLenghtQuery).fill(0);
    lineNumber++;
  } else if (lineNumber > 2) {
    listQuery.push(parseInt(line));
    lineNumber++;
    if (lineNumber === listLenghtQuery + 3) {
      for (let index = 0; index < listLengthInput; index++) {
        let num = listNumber[index];
        for (let query of listQuery) {
          queryIndex = listQuery.indexOf(query);
          if (Number(num) > Number(query)) {
            listVerify[queryIndex] = listVerify[queryIndex] + 1;
          }
        }
      }
      listVerify.map((count) => console.log(count));
    }
  }
}