# n, h, t 입력
n, h, t = map(int, input().split())
# field_list 입력
field_list = list(map(int, input().split()))
# 함수들
# calc(s, e)
def calc(s, e):
# curr_cost
curr_cost = 0
# 해당 범위 내에서
for i in range(s, e):
# curr_cost에 차이 추가
curr_cost += abs(field_list[i] - h)
# 반환
return curr_cost
# 설계
# lowest_cost
import sys
lowest_cost = sys.maxsize
# 완전 탐색 시작
for i in range(n-t+1):
# lowest_cost 업데이트
lowest_cost = min(lowest_cost, calc(i, i+t))
# 출력
print(lowest_cost)
'Algorithm(CodeTree, Python) > 완전탐색1' 카테고리의 다른 글
[코드트리 자리 마다 숫자를 정하는 완전탐색] 개발자의 능력 3 python (0) | 2022.12.11 |
---|---|
[코드트리 자리 마다 숫자를 정하는 완전탐색] 한 가지로 열리는 자물쇠python (0) | 2022.12.11 |
[코드트리 구간 단위로 완전탐색] G or H 2 python (0) | 2022.12.09 |
[코드트리 구간 단위로 완전탐색] 바구니 안의 사탕 2 python (0) | 2022.12.08 |
[코드트리 구간 단위로 완전탐색] 특정 구간의 원소 평균값 python (0) | 2022.12.07 |