IM대비

백준 14696 <딱지놀이>

마이보 2020. 9. 24. 09:11
728x90

각각의 라운드마다 A B 배열을 만들고 개수를 확인하면서 출력하는 문제이다.

 

전체 코드

더보기
package asd;

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

public class sad {
	
	public static void main(String[] args) throws IOException {
		int n,k;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));	
		n=Integer.parseInt(br.readLine());
		for(int i=1;i<=n;i++) {
			int numa[]=new int[5];
			int numb[]=new int[5];
			
			StringTokenizer st=new StringTokenizer(br.readLine());
			int num=Integer.parseInt(st.nextToken());
			for(k=0;k<num;k++) {
				numa[Integer.parseInt(st.nextToken())]++;
			}
			st=new StringTokenizer(br.readLine());
			num=Integer.parseInt(st.nextToken());
			for(k=0;k<num;k++) {
				numb[Integer.parseInt(st.nextToken())]++;
			}
			if(numa[4]<numb[4]) {
				System.out.println("B");
			}
			else if(numa[4]>numb[4]) {
				System.out.println("A");
			}else if(numa[3]<numb[3]) {
				System.out.println("B");
			}else if(numa[3]>numb[3]) {
				System.out.println("A");
			}else if(numa[2]<numb[2]) {
				System.out.println("B");
			}else if(numa[2]>numb[2]) {
				System.out.println("A");
			}else if(numa[1]<numb[1]) {
				System.out.println("B");
			}else if(numa[1]>numb[1]) {
				System.out.println("A");
			}else
				System.out.println("D");
			
			
		}
		
	}

}