| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 18110 |
| 문제명 | solved.ac |
| 레벨 | 실버 4 |
| 분류 |
기초 |
| 시간복잡도 | O(nlogn) |
| 인풋사이즈 | n <= 3*10^5 |
| 사용한 언어 | Python 3.11 |
| 제출기록 | 38352KB / 148ms |
| 최고기록 | 144ms |
| 해결날짜 | 2023/06/05 |
"""Solution code for "BOJ 18110. solved.ac".
- Problem link: https://www.acmicpc.net/problem/18110
- Solution link: http://www.teferi.net/ps/problems/boj/18110
"""
import sys
def round_half_up(x):
if x > 0:
return int(x) + 1 if x - int(x) >= 0.5 else int(x)
else:
return int(x) - 1 if int(x) - x >= 0.5 else int(x)
def main():
n = int(sys.stdin.readline())
ratings = [int(sys.stdin.readline()) for _ in range(n)]
if n == 0:
print('0')
return
exclusion_count = round_half_up(n * 0.15)
effective_ratings = (
ratings
if exclusion_count == 0
else sorted(ratings)[exclusion_count:-exclusion_count]
)
answer = round_half_up(sum(effective_ratings) / len(effective_ratings))
print(answer)
if __name__ == '__main__':
main()