[백준/BOJ] 29615. 알파빌과 베타빌 [Silver 5]

jychan99·2023년 9월 19일
0

  1. 알파빌과 베타빌
    문제출처 : https://www.acmicpc.net/problem/29615
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static int N,M,cnt=0;
    static int[] list,friend;

    public static void main(String args[])throws IOException{
        st = new StringTokenizer(br.readLine()," ");
        N = Integer.parseInt(st.nextToken());
        M = Integer.parseInt(st.nextToken());
        
        list = new int[N];
        friend = new int[M];
        st = new StringTokenizer(br.readLine()," ");

        for(int i=0;i<N;i++){
            list[i] = Integer.parseInt(st.nextToken());
        }
        
        st = new StringTokenizer(br.readLine()," ");
        for(int i=0;i<M;i++){
            friend[i] = Integer.parseInt(st.nextToken());
        }

        for(int i =0;i<M;i++){
            for(int j=0;j<M;j++){
                if(list[j]==friend[i]){
                    cnt++;
                }
            }
        }
        System.out.println(M-cnt);
        
    }
}

굳이 위치를 안바꾸고 대기명단 M번째안에 내 친구이름이 없으면 넣으면된다.

profile
내가 지금 두려워 하고 있는 일이 바로 내가 지금 해야 할 일이다. 🐥

0개의 댓글