题目链接
https://pintia.cn/problem-sets/994805046380707840/problems/994805062432309248
思路我们只需要在每一个同学的评分中算出总和评分和最低最高评分即可,对于最高评分,我们定义一个
m
a
x
w
max_w
maxw 初始化为
0.0
0.0
0.0 然后遍历的过程中不断取 max
最低分同理,然后我们取一个平均值,放入数组或者容器中,最后排序输出前
m
m
m 名同学即可
#include
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n"
#define PII pair
#define INF 0x3f3f3f3f
int n,k,m;
vector 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 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());
cout
关注
打赏