[백준]S4-2108

py_code·2021년 1월 12일
0

백준-실버4

목록 보기
3/7

import sys # 입력값이 많을 경우 input() 보단 sys.stdin.readline()
n = int(input())
L = sorted(list(int(sys.stdin.readline()) for _ in range(n)))

print(round(sum(L)/n))
print( L[(n-1)//2] )

from collections import Counter
L_cnt=Counter(L).most_common()
if n > 1: # n==1 이면 1개 입력된 값만 출력하면 되므로 조건 분기 필요
    if L_cnt[0][1] == L_cnt[1][1]:print(L_cnt[1][0]) # count가 같은게 여러개면 2번째 값 출력
    else : print(L_cnt[0][0]) # count most가 1개면 바로 출력
else : print(L[0]) 

print(max(L)-min(L))
profile
개발자를 꿈꿉니다.

0개의 댓글