#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
const int M = 110;
int n, m;
struct stu
{
string a;
int t[M], s;
} a[N];
bool cmp(stu a, stu b)
{
if (a.s != b.s)
return a.s > b.s;
for (int i = 0; i < m; i++)
{
if (a.t[i] != b.t[i])
return a.t[i] > b.t[i];
}
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> a[i].a;
a[i].s = 0;
for (int j = 0; j < m; j++)
{
cin >> a[i].t[j];
a[i].s += a[i].t[j];
}
}
sort(a, a + n, cmp);
for (int i = 0; i < n; i++)
cout << a[i].a << ' ';
cout << '\n';
}
C++ STL香
羡慕大佬QAQ
还是更习惯运算符重载QAQ