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

Envío 4493

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

  • Autor: pablopvsky
  • Fecha: 2021-07-04 02:36:31 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.065 s 17 KBi
#2
Correcto
0.053 s 7 KBi
#3
Correcto
0.046 s 8 KBi
#4
Correcto
0.052 s 7 KBi
#5
Correcto
0.063 s 10 KBi
#6
Correcto
0.063 s 17 KBi
#7
Correcto
0.061 s 7 KBi
#8
Correcto
0.049 s 7 KBi
#9
Correcto
0.071 s 23 KBi
#10
Correcto
0.07 s 13 KBi
Puntos totales: 100 / 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 queryIndex = 0; queryIndex < listLenghtQuery; queryIndex++) {
          if (Number(num) > Number(listQuery[queryIndex])) {
            listVerify[queryIndex] = Number(listVerify[queryIndex]) + 1;
          }
        }
      }
      listVerify.map((count) => console.log(count));
    }
  }
}