题解:
cpp
#include<bits/stdc++.h>
using namespace std;
struct tree {
int id;
int apple;
int cut = 0;
};
bool cmp(tree a, tree b)
{
if (a.cut == b.cut)
{
return a.id < b.id;
}
return a.cut > b.cut;
}
int main()
{
int n, m;
cin >> n >> m;
tree t[n];
int cutNum = 0;
for (int i = 0; i < n; i++)
{
cin >> t[i].apple;
t[i].id = i + 1;
for (int j = 0; j < m; j++)
{
cin >> cutNum;
t[i].cut += (-cutNum);
}
t[i].apple -= t[i].cut;
}
int sum = 0;
sort(t, t + n, cmp);
for (int i = 0; i < n; i++)
{
sum += t[i].apple;
}
cout << sum << " " << t[0].id << " " << t[0].cut << endl;
return 0;
}