• 문제 링크
15233번: Final Score
We have had a problem with one of our hard disks and we lost the final score of some football matches. However, we have been able to recover the names of the players that scored and found the members of each team on Wikipedia.
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;
import java.util.StringTokenizer;
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));
StringTokenizer st = new StringTokenizer(br.readLine());
st.nextToken();
int b = Integer.parseInt(st.nextToken());
int g = Integer.parseInt(st.nextToken());
br.readLine();
Set<String> set = new HashSet<>();
st = new StringTokenizer(br.readLine());
while (b-- > 0) set.add(st.nextToken());
int a = -1;
st = new StringTokenizer(br.readLine());
while (g-- > 0) {
if (set.contains(st.nextToken())) b++;
else a++;
}
bw.write(a == b ? "TIE" : a > b ? "A" : "B");
bw.flush();
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 10657 Cow Jog - Data Structure / Java (0) | 2023.06.30 |
---|---|
[백준] 10527 Judging Troubles - Data Structure / Java (0) | 2023.06.29 |
[백준] 13915 Hot Air Ballooning - Data Structure / Java (0) | 2023.06.27 |
[백준] 5957 Cleaning the Dishes - Data Structure / Java (0) | 2023.06.26 |
[백준] 4921 나무 블록 - Data Structure / Java (0) | 2023.06.25 |
댓글