Skip to content

Commit 36a6ad7

Browse files
committed
[Silver IV] Title: 듣보잡, Time: 212 ms, Memory: 24880 KB -BaekjoonHub
1 parent d41a339 commit 36a6ad7

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# [Silver IV] 듣보잡 - 1764
2+
3+
[문제 링크](https://www.acmicpc.net/problem/1764)
4+
5+
### 성능 요약
6+
7+
메모리: 24880 KB, 시간: 212 ms
8+
9+
### 분류
10+
11+
자료 구조, 문자열, 정렬, 집합과 맵, 해시를 사용한 집합과 맵
12+
13+
### 제출 일자
14+
15+
2026년 2월 27일 14:35:24
16+
17+
### 문제 설명
18+
19+
<p>김진영이 듣도 못한 사람의 명단과, 보도 못한 사람의 명단이 주어질 때, 듣도 보도 못한 사람의 명단을 구하는 프로그램을 작성하시오.</p>
20+
21+
### 입력
22+
23+
<p>첫째 줄에 듣도 못한 사람의 수 N, 보도 못한 사람의 수 M이 주어진다. 이어서 둘째 줄부터 N개의 줄에 걸쳐 듣도 못한 사람의 이름과, N+2째 줄부터 보도 못한 사람의 이름이 순서대로 주어진다. 이름은 띄어쓰기 없이 알파벳 소문자로만 이루어지며, 그 길이는 20 이하이다. N, M은 500,000 이하의 자연수이다.</p>
24+
25+
<p>듣도 못한 사람의 명단에는 중복되는 이름이 없으며, 보도 못한 사람의 명단도 마찬가지이다.</p>
26+
27+
### 출력
28+
29+
<p>듣보잡의 수와 그 명단을 사전순으로 출력한다.</p>
30+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"use strict";
2+
3+
const fs = require("fs");
4+
const input = fs
5+
.readFileSync(process.platform === "linux" ? "/dev/stdin" : "./input.txt")
6+
.toString()
7+
.trim()
8+
.split("\n");
9+
10+
const [N, M] = input[0].split(" ").map(Number);
11+
12+
const unheard = new Set(); //듣도 못한 사람
13+
14+
for (let i = 1; i <= N; i++) {
15+
unheard.add(input[i].trim());
16+
}
17+
18+
const result = [];
19+
20+
for (let i = N + 1; i <= N + M; i++) {
21+
const name = input[i].trim();
22+
23+
if (unheard.has(name)) {
24+
result.push(name);
25+
}
26+
}
27+
28+
result.sort();
29+
30+
console.log(result.length);
31+
if (result.length > 0) {
32+
console.log(result.join("\n"));
33+
}

0 commit comments

Comments
 (0)