반응형
백준 2108 구현
https://www.acmicpc.net/problem/2108
# 2108
from collections import Counter
import sys
n = int(sys.stdin.readline())
l = [0]*n
for i in range(n):
tmp = int(sys.stdin.readline())
l[i] = tmp
l.sort()
cnt = Counter(l).most_common(2)
print(round(sum(l)/n))
print(l[(n)//2])
if len(cnt) == 1:
print(l[0])
else:
if cnt[0][1] > cnt[1][1]:
print(cnt[0][0])
else:
print(cnt[1][0])
print(l[-1]-l[0])
반응형
'algorithm test' 카테고리의 다른 글
[baekjoon 백준][python] 1966 (0) | 2023.02.14 |
---|---|
[프로그래머스][python]게임맵최단거리 DFS&BFS (0) | 2023.02.14 |
[baekjoon 백준][python] 20044 greedy (0) | 2023.02.02 |
[baekjoon 백준][python] 5585 greedy (0) | 2023.02.02 |
[baekjoon백준][python] 2839 (2) | 2023.02.02 |