#include <stdio.h>
#include <math.h>

int main() {
    int n,remove,sum=0;
    //1-30까지 몇개인지 저장
    int num[31]={0};
    scanf("%d",&n);
    if (n==0) {
        printf("0");
        return 0;
    }
    for(int i=1; i<=n; i++) {
        int k;
        scanf("%d",&k);
        num[k]+=1;
        sum+=k;
        }
    
    //제거할 갯수
    remove= round(n*0.15);
    int tmp_remove=remove;
    //제거할 수가 0이면 다음 (최솟값)
    for(int i=1; i<=30; i++) {
        if(num[i]==0) continue;
        //제거할 수보다 많으면 제거할수만큼만 전체어서 뻄
        if(num[i]>=tmp_remove) {
            sum-=i*tmp_remove;
            break;
        }
        //제거할수가 많으면 다음으로
        else  {
            sum-=i*num[i];
            tmp_remove-=num[i];
        }
    }
    tmp_remove=remove;

    //(최댓값)제거
    for(int i=30; i>=1; i--) {
        if(num[i]==0) continue;
        //제거할 수보다 많으면 제거할수만큼만 전체어서 뻄
        if(num[i]>=tmp_remove) {
            sum-=i*tmp_remove;
            break;
        }
        //제거할수가 많으면 다음으로
        else  {
            sum-=i*num[i];
            tmp_remove-=num[i];
        }
    }
    double r=(n-2*remove);
    printf("%d",(int)round(sum/r));
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: