1부터 2,3,4 순서에 맞춰서 배열에서 해당하는 수를 찾아야 한다. 그래서 그리디 알고리즘에 해당하는 문제이다.
n= int(input())
arr= list(map(int, input().split()))
total_len = len(arr)
num_index = 0
tofind = 1
ans = 0
if 1 not in arr :
print(n)
exit()
while num_index < total_len :
if arr[num_index] == tofind :
ans +=0
tofind += 1
num_index+= 1
else :
ans += 1
num_index += 1
print(ans)
'알고리즘 문제풀이' 카테고리의 다른 글
강의실 예약 시스템(백준30019) (0) | 2023.09.19 |
---|---|
타슈 (백준 30018) (0) | 2023.09.18 |
동전 복사(백준 28063) (0) | 2023.09.16 |
반복 (백준 19564) (0) | 2023.09.14 |
Pen Pineapple Apple Pen (백준15881) (0) | 2023.09.14 |