https://pintia.cn/problem-sets/994805260223102976/problems/994805262303477760
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int N, M;
cin >> N >> M;
for(int i = 0; i < N; i++){
int tmp, score[500] = {0}, cnt = 0;
double G1 = 0.0, G2;
cin >> G2;
for(int j = 1; j < N; j++){
cin >> tmp;
if(tmp >= 0 && tmp <= M)
score[cnt++] = tmp;
}
sort(score, score+cnt);
for(int i = 1; i < cnt-1; i++)
G1 += score[i];
cnt -= 2;
cout << (int)((G1/cnt + G2)/2.0+0.5) << endl;
}
return 0;
}
本文解析了一道C++编程竞赛题目,通过读取输入数据并进行特定算法处理,最终输出处理结果。涉及的主要步骤包括读取整数、条件判断、数组操作、排序算法及双精度浮点数运算。
1208

被折叠的 条评论
为什么被折叠?



