n = int(input())
store = list(map(int,input().split()))
cnt = 0
for i in range(n):
if store[i] == cnt % 3:
cnt += 1
print(cnt)
같이 문제를 풀었던 친구는 아래와 같은 식으로 풀었다.
input()
store = list(input().split())
cnt = 0
milk_state = 0
for i in store:
if int(i) == milk_state:
milk_state += 1
cnt += 1
if milk_state > 2:
milk_state = 0
print(cnt)
'개발 > Algorithm' 카테고리의 다른 글
[프로그래머스] 요격 시스템 (Java 풀이) (0) | 2023.04.16 |
---|---|
[Python] 백준 9093번 단어 뒤집기 (0) | 2021.11.15 |
[Python] 백준 15650번 N과 M (2) (0) | 2021.11.15 |
[Python] 백준 15649번 N과 M (1) (0) | 2021.11.15 |
[Python] 백준 1260번 DFS와 BFS (0) | 2021.11.12 |
댓글