Contest Duration: - (local time) (100 minutes) Back to Home
Official

## B - Trimmed Mean Editorial by en_translator

Among several approaches, the simplest one is to sort the grades by the $$5N$$ judges and then find the average from the $$(N+1)$$-th through $$4N$$-th ones.

Generally, it is sufficiently fast and easy to use the predefined function in principle. However, since $$N$$ is about $$100$$, manual implementation of sorting algorithms like bubble sort will also do. Be sure to convert the sum from integer type to (floating or fixed) decimal type before taking the average.

Sample code in C++:

#include <bits/stdc++.h>
using namespace std;

int main() {
int n;
double sum=0.0;
cin>>n;

vector<double> a(5*n);
for(int i=0;i<5*n;i++)cin>>a[i];

sort(a.begin(),a.end());
for(int i=n;i<4*n;i++)sum+=a[i];
cout<<sum/((double)(3*n))<<endl;

return 0;
}


Sample code in Python:

import numpy as np

n=int(input())
a=list(map(float,input().split()))
a.sort()
print(np.mean(a[n:4*n]))


posted:
last update: