1077 互评成绩计算 (20 分)

79 阅读1分钟

1077 互评成绩计算 (20 分)

题目链接

算法分析:

唯一的亮点就是去掉最高分和去掉最低分的处理吧,其它的也不难。

代码实现

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

int main(){
	int n, m;
	int ther, stu;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++ i){
		int Min = 1e9, Max = -1;
		int sum = 0, cnt = 0;
		scanf("%d", &ther);
		for(int j = 1; j <= n - 1; ++ j){
			scanf("%d", &stu);
			if(stu >= 0 && stu <= m){
				Min = min(stu, Min);
				Max = max(stu, Max);
				sum += stu;	
				cnt ++;	
			}
		}
		printf("%d\n", (int)(((sum - Min - Max ) * 1.0 / (cnt - 2) + ther) / 2.0 + 0.5));
	}
	return 0;
}