ALGORITHM/PYTHON

백준 BAEKJOON 29615번 알파빌과 베타빌 [PYTHON/파이썬]

칼코
반응형

 

 

 

 

 

백준 BAEKJOON 29615번 알파빌과 베타빌 [PYTHON/파이썬]


<문제 출처> (SILVER Ⅴ)

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

 

29615번: 알파빌과 베타빌

$1$번과 $3$번을 바꾸고 $2$번과 $4$번을 바꾸면 $3\,4\,1\,2\,5$가 되어 모든 친구들이 먼저 입주할 수 있다.

www.acmicpc.net

 

 

 

 

 

 

<풀이>

친구의 수가 몇 명인지 파악 후

명단의 앞에서부터 친구의 유무를 확인해 주면 된다.

 

 

 

 

 

 

 

<코드>

N, M = map(int, input().split())
citizenList = input().split()
friends = input().split()

result = 0
for c in citizenList[:M]:
    if c not in friends:
        result += 1

print(result)

 

 

 

 

 

 

반응형