原题链接:PTA | 程序设计类实验辅助教学平台
Tips:以下Python代码仅个人理解,非最优算法,仅供参考!多学习其他大佬的AC代码!
n, m = map(int, input().split())
for i in range(n):
mark = list(map(int, input().split()))
g2 = mark[0]
ls = []
for j in mark[1:]:
if 0 <= j <= m:
ls.append(j)
ls.remove(max(ls))
ls.remove(min(ls))
g1 = sum(ls) / len(ls)
score = int((g1 + g2) / 2 + 0.5)
print(score)