Pat B (Basic level) 1047 (c + +) __c++

Source: Internet
Author: User

1047. Programming Team (20)

The rules of the programming team are: Each of the teams is composed of a number of players, all players are independent of the competition, the team's results for all the team's performance and the highest-score team wins.

Now given the results of all players, please write a program to find the champions team.

Input format:

Enter the first line to give a positive integer n (<=10000), that is, the total number of participants. Then n rows, each line gives a player's score in the form: "Team number-player number score", where "team number" is a positive integer from 1 to 1000, "player number" is a positive integer of 1 to 10, and "score" is an integer of 0 to 100.

Output format:

The number and total score of the Champions team are output in one line, separated by a single space. Note: The title Guarantee team is unique. Input Sample:

6
3-10
11-5
102-1 0
102-3
11-9
3-2 61
Output Sample:
11 176
C++

#include <iostream>
using namespace std;
int main () {
	int n;//total number
	of players int duiwu,duiyuan,chengji;//team number, player number, score
	int maxduiwu=0,maxchengji=0;// Highest-scoring team, highest score
	int score[10001]={0};//score array record score
	cin>>n;
	for (int i=0;i<n;i++) {
		scanf ("%d-%d%d", &duiwu,&duiyuan,&chengji);//%d input integer 
	    score[duiwu]= score[duiwu]+chengji;//Statistic Team score
		 if (Score[duiwu]>maxchengji) {//traverse highest 
		 	Maxchengji=score[duiwu];
		 	Maxduiwu=duiwu
		 } 
	} 
	cout<<maxduiwu<< "" <<maxchengji;
	return 0;
}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.