백준. 2108번. 통계학 파이썬 풀이
문제링크 https://www.acmicpc.net/problem/2108
문제가 별로다
import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
# 수 저장
array = []
# 평균을 계산하기 위한 전체 수의 합
sum_ = 0
for _ in range(n):
temp = int(input())
array.append(temp)
sum_ += temp
array.sort()
# Counter를 활용하여 최빈값 계산
count = Counter(array)
count = sorted(count.items(), key=lambda x: (-x[1], x[0]))
# 산술평균
print(round(sum_/n))
# 중앙값
print(array[len(array)//2])
# 최빈값
if len(count) > 1:
if count[0][1] == count[1][1]:
print(count[1][0])
else:
print(count[0][0])
else:
print(count[0][0])
# 범위
print(array[-1]-array[0])