#include <stdio.h>
#include <math.h>
int main() {
int n;
// 1. n을 먼저 입력받아야 합니다.
if (scanf("%d", &n) != 1 || n == 0) {
printf("0\n");
return 0;
}
// 2. 1-30까지 빈도수 저장
int num[31] = {0};
for (int i = 0; i < n; i++) {
int val;
scanf("%d", &val);
num[val]++;
}
// 3. n을 받은 후에 절사 범위 계산
int remove = (int)round(n * 0.15);
int left = remove; // 앞쪽 경계
int right = n - remove; // 뒤쪽 경계
double sum = 0;
int current = 0; // 누적 인원수
// 4. 1점부터 30점까지 순회 (Counting Sort 로직)
for (int i = 1; i <= 30; i++) {
if (num[i] == 0) continue;
int next = current + num[i]; // 현재 점수 뭉텅이의 끝 지점
// 삼항연산자로 시작과 끝점 결정
int start = (current > left) ? current : left;
int end = (next < right) ? next : right;
// 5. 겹치는 인원이 있다면 (사람 수 * 점수)를 합산
if (start < end) {
sum += (double)(end - start) * i;
}
current = next; // 다음 점수 뭉텅이를 위해 업데이트
}
// 6. 최종 평균 출력 (n-2*remove 로 나누기)
printf("%d\n", (int)round(sum / (n - 2 * remove)));
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: