알고리즘/SWEA
[파이썬] [SWEA] 1206. [S/W 문제해결 기본] 1일차 - View
SBOX Learning by doing
2021. 2. 20. 16:18
반응형
swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV134DPqAA8CFAYh
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
1. normal
T = 10 # 대문자 상수
for tc in range(1, T+1):
N = int(input())
arr = list(map(int, input().split()))
ans = 0
# 2 ~ N-2 각각 검사해서
for i in range(2, N-2):
min_value = 987654321
# 기준 건물과 왼쪽 오른쪽 2개 차의 최소값
for j in range(5):
if j != 2:
if arr[i] - arr[i-2+j] < min_value:
min_value = arr[i] - arr[i-2+j]
# 최소값이 양수이면 조망권이 확보
if min_value > 0 :
ans += min_value
print("#{} {}".format(tc, ans))
반응형