목차

solved.ac

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()