• 문제 링크
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();
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 9255 The Friend of My Enemy is My Enemy - Graph Theory / Java (0) | 2024.01.06 |
---|---|
[백준] 6601 Knight Moves - Graph Theory / Java (0) | 2024.01.05 |
[백준] 9843 LVM - Data Structure / Java (0) | 2024.01.03 |
[백준] 6119 Cow Line - Data Structure / Java (0) | 2024.01.02 |
[백준] 2371 파일 구별하기 - Data Structure / Java (0) | 2024.01.01 |
댓글