Problem Solving/Baekjoon
[백준] 8975 PJESMA - Data Structure / Java
graycode
2024. 1. 4. 21:36
• 문제 링크
8975번: PJESMA
"Guess the song" is a popular game among young programmers in Croatia. It is a game of skill, wisdom and patience. The game host plays a song so that all players hear it. The players' goal is to guess the title of the song as fast as possible. Mirko may
www.acmicpc.net
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
Set<String> set = new HashSet<>();
int n = Integer.parseInt(br.readLine()), m = (n + 1) / 2;
while (n-- > 0) set.add(br.readLine());
br.readLine();
int cnt = 0;
while (m > 0) {
String s = br.readLine();
if (set.remove(s)) m--;
cnt++;
}
bw.write(String.valueOf(cnt));
bw.flush();
}
}