코딩테스트/백준

[백준]14696번 딱지놀이 - Java

GAEBAL 2022. 2. 25. 16:15
728x90

문제

https://www.acmicpc.net/problem/14696

 

14696번: 딱지놀이

표준 입력으로 다음 정보가 주어진다. 첫 번째 줄에는 딱지놀이의 총 라운드 수를 나타내는 자연수 N이 주어진다. N 은 1 이상 1,000 이하이다. 다음 줄에는 라운드 1에서 어린이 A가 내는 딱지에 나

www.acmicpc.net

 

풀이

단순하고 무식하게 문제가 시키는대로 해서 풀었음.

걍 했음

오히려 입력받는게 헷갈릴 수도,,,???

코드

// 14696번 딱지놀이
// https://www.acmicpc.net/problem/14696

package BAEKJOON;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Num14696_딱지놀이 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        int N = Integer.parseInt(br.readLine());
        for (int i = 1; i <= N; i++) {
            int A[] = new int[5];
            int B[] = new int[5];

            st = new StringTokenizer(br.readLine());
            int num = Integer.parseInt(st.nextToken());
            for (int j = 0; j < num; j++) {
                A[Integer.parseInt(st.nextToken())]++;
            }

            st = new StringTokenizer(br.readLine());
            num = Integer.parseInt(st.nextToken());
            for (int j = 0; j < num; j++) {
                B[Integer.parseInt(st.nextToken())]++;
            }

            if (A[4] < B[4]) {
                System.out.println("B");
            } else if (A[4] > B[4]) {
                System.out.println("A");
            } else if (A[3] < B[3]) {
                System.out.println("B");
            } else if (A[3] > B[3]) {
                System.out.println("A");
            } else if (A[2] < B[2]) {
                System.out.println("B");
            } else if (A[2] > B[2]) {
                System.out.println("A");
            } else if (A[1] < B[1]) {
                System.out.println("B");
            } else if (A[1] > B[1]) {
                System.out.println("A");
            } else {
                System.out.println("D");
            }
        }
    }
}
728x90