topic link
https://pintia.cn/problem-sets/994805046380707840/problems/994805062432309248
ideas
We only need to calculate the total score and the lowest and highest score in each classmate's score. For the highest score, we define a maxw max_wmaxwinitialized to 0.0 0.00.0 and then continuously take the lowest score during the traversalmax
process , and then we take an average value, put it into an array or container, and finally sort the output before mmm students can
code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n"
#define PII pair<int,int>
#define INF 0x3f3f3f3f
int n,k,m;
vector<double> V;
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>k>>m;
double t;
for(int i = 1;i <= n; ++i) {
double sum = 0.0,max_w = 0.0,min_w = 100.0;
for(int j = 1;j <= k; ++j) {
cin>>t;
sum += t;
max_w = max(max_w,t);
min_w = min(min_w,t);
}
sum -= max_w + min_w;
sum /= k - 2.0;
V.push_back(sum);
}
sort(V.begin(),V.end(),greater<double>());
cout<<fixed<<setprecision(3);
for(int i = m - 1;i >= 0; --i)
cout<<V[i]<<" \n"[i == 0];
return 0;
}