[NOIP 2007 普及组 T1] 奖学金

作者: qiqi 分类: CSP-J 发布时间: 2025-10-06 13:25

查看题目

#include <bits/stdc++.h>
using namespace std;

struct Stu
{
	int id;
	int yw, sx, yy;
	int score;
} x[310];

bool cmp(Stu a, Stu b)
{
	if (a.score > b.score)
		return true;
	else if (a.score == b.score && a.yw > b.yw)
		return true;
	else if (a.score == b.score && a.yw == b.yw && a.id < b.id)
		return true;
	return false;
}

int main()
{
	int n, sx, yw, yy;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> yw >> sx >> yy;
		x[i].id = i + 1;
		x[i].sx = sx, x[i].yw = yw, x[i].yy = yy;
		x[i].score = sx + yw + yy;
	}

	sort(x, x + n, cmp);

	for (int i = 0; i < 5; i++)
	{
		cout << x[i].id << ' ' << x[i].score << endl;
	}

	return 0;
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

标签云