Algorithm/Greedy

[백준] 14720번 우유 축제

등촌동 꼬북이 2020. 10. 6. 18:54

쉬운 문제

 

이지만.. 조금 헤멤... 댕청.. 

N = int(input())
S = list(map(int, input().split()))
counter = 0
current = 0
for i in range(len(S)):
    if S[i] == current:
        counter += 1
        current += 1
        if current == 3:
            current = 0
print(counter)