题目链接
实现
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main()
{
int N, M, G1, G2,i,j,temp;
cin >> N >> M;
for (i = 0; i < N; i++)
{
cin >> G2;
vector<int> score;
for (j = 0; j < N - 1; j++)
{
cin >> temp;
if (temp >= 0 && temp <= M)
score.push_back(temp);
}
int maxIndex = max_element(score.begin(), score.end())-score.begin();
score.erase(score.begin()+maxIndex);
int minIndex = min_element(score.begin(), score.end()) - score.begin();
score.erase(score.begin()+minIndex);
int sumScore = accumulate(score.begin(), score.end(), 0);
cout << round((sumScore*1.0 / score.size()+G2)/2) << endl;
}
return 0;
}