PAT1047 编程团体赛 (20 分)

题目

在这里插入图片描述

代码

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int teamNum;
	int personNum;
	int score;

	int total;
	cin >> total;

	int team[1001] = { 0 };
	int i;
	for (i = 0; i < total; i++)
	{
		scanf("%d-%d %d", &teamNum, &personNum, &score);
		team[teamNum] += score;
	}

	int maxScore = 0, maxNum;
	for (i = 0; i < 1001; i++)
	{
		if (team[i] > maxScore)
		{
			maxNum = i;
			maxScore = team[i];
		}
	}

	cout << maxNum << ' ' << maxScore << endl;
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/sinat_42483341/article/details/87938296
今日推荐