코딩테스트 파이썬/파이썬 프로그래머스 3단계
Softeer 연습문제(1단계) - 연탄 배달의 시작
세용용용용
2024. 6. 24. 20:56
Candidate | Softeer Assessment UI
softeer.ai
나의 코드
import sys
input = sys.stdin.readline
m_ct = int(input().strip())
m_list = list(map(int, input().split()))
# 최솟값 변수양의 무한대로 초기값
min_length = float('inf')
min_count = 0
for i in range(1, m_ct):
now_value = abs(m_list[i] - m_list[i - 1])
if now_value < min_length:
min_length = now_value
min_count = 1
elif now_value == min_length:
min_count += 1
print(min_count)
오늘 배운것 : 최솟값 변수 양의 무한대로 초기화
초기변수명=float('inf')