看清总评价的计算公式后利用 structsort 排序即可。

为了避免精度误差,建议按 k=(2m+n)tk=(2m+n)t(将原来的公式除以 0.030.03)计算总评价,此时需要使用 long long。(当然了,直接使用 doublelong double 也是一个不错的选择。)

#include <bits/stdc++.h>
using namespace std;
const int A = 20 + 2;
struct Team
{
	string b;
	int m;
	int n;
	int t;
	long long k;
};
Team team[A];
bool cmp(Team x, Team y)
{
	return x.k > y.k;
}
int main()
{
	freopen("football.in", "r", stdin);
	freopen("football.out", "w", stdout);
	int T;
	cin >> T;
	while (T--)
	{
		int a;
		cin >> a;
		for (int i = 1; i <= a; i++)
		{
			cin >> team[i].b >> team[i].m >> team[i].n >> team[i].t;
			team[i].k = 1ll * team[i].t * (2ll * team[i].m + 1ll * team[i].n);
		}
		sort(team + 1, team + a + 1, cmp);
		for (int i = 1; i <= a; i++)
		{
			cout << team[i].b;
			if (i != a) cout << ' ';
		}
		cout << endl;
	}
	return 0;
}