유물/└ 백준
<백준> 10871번: X보다 작은 수
디벅잉
2022. 1. 3. 20:19
728x90
🤖
문제
https://www.acmicpc.net/problem/10871
10871번: X보다 작은 수
첫째 줄에 N과 X가 주어진다. (1 ≤ N, X ≤ 10,000) 둘째 줄에 수열 A를 이루는 정수 N개가 주어진다. 주어지는 정수는 모두 1보다 크거나 같고, 10,000보다 작거나 같은 정수이다.
www.acmicpc.net
풀이
const fs = require("fs");
const input = fs.readFileSync("/dev/stdin").toString().split("\n");
const N = parseInt(input[0].split(" ")[0]);
const X = parseInt(input[0].split(" ")[1]);
const A = input[1].split(" ");
let result = [];
for (let i = 0; i < N; i++) {
if (A[i] < X) {
result.push(A[i]);
}
}
console.log(result.join(" "));
728x90