#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
struct student{
string name;
double val;
};
double cnt[21];
vector <student> s;
bool cmp(student a, student b) {
if (a.val == b.val) return a.name < b.name;
return a.val > b.val;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
student s1;
cin >> s1.name;
double ki = 0.0;
for (int j = 0; j < m; j++) {
cin >> cnt[j];
ki += cnt[j];
}
ki /= (double)m;
for (int j = 0; j < m; j++)
s1.val += pow(cnt[j] - ki, 2);
s1.val = sqrt(s1.val / (double)m);
s.push_back(s1);
memset(cnt, 0, sizeof(cnt));
}
sort(s.begin(), s.end(), cmp);
for (int i = 0; i < min(n, 20); i++)
cout << s[i].name << '\n';
return 0;
}
交了 n 次,这份60分, WA 了 #1 #4 #8 #10 。 求助 o(╥﹏╥)o