a에 리스트 저장한 후에
a로 조망이 확보 되는지 확인 한 후 확보되면
-1 하면서
확보되지 않을 때 까지
cnt 를 올려주는 방식으로 풀이했다.
import sys
sys.stdin = open('input.txt')
for test in range(10):
x = int(input())
lst = list(map(int, input().split()))
total = 0
for lstIdx in range(2, x-2):
cnt = 0
a = lst[lstIdx]
while a > lst[lstIdx-1] and a > lst[lstIdx-2] and a > lst[lstIdx+1] and a > lst[lstIdx+2]:
cnt +=1
a -=1
total += cnt
print(f'#{test+1} {total}')
'알고리즘 > SWEA' 카테고리의 다른 글
[swea][파이썬] 13627 .전기버스 (0) | 2022.08.22 |
---|---|
[swea][파이썬] 13626 .구간합 (0) | 2022.08.22 |
[swea][파이썬] 13624 .숫자 카드 (0) | 2022.08.22 |
[swea][파이썬] 13623 .min max (0) | 2022.08.22 |
[swea][파이썬] 1208. [S/W 문제해결 기본] 1일차 - Flatten (0) | 2022.08.22 |