题目链接:
题解:
1 /* 2 *不要把本题的输入格式想成字符串的处理,这样本题就复杂了。 3 * 在输入 "队伍编号-队员编号 成绩" 中的 '-队员编号' 可以看成一个负的整数, 4 *所以可以看成由3个整型变量构成,因此定义了结构体,但是由于队员编号在本题目中 5 *没有用,所以不定义都行 6 */ 7 #include8 #include 9 using namespace std;10 const int MAXN = 1000 + 5;11 12 struct Group {13 int team_number;14 int score;15 };16 void Initate(Group obj[]) {17 for (int i = 0; i < MAXN; i++) {18 obj[i].team_number = 0;19 obj[i].score = 0;20 }21 }22 int main() {23 int n;24 cin >> n;25 Group obj[MAXN];26 Initate(obj);27 for (int i = 0; i < n; i++) {28 int temp1, temp2, temp3;29 cin >> temp1 >> temp2 >> temp3;30 obj[temp1].score += temp3;31 }32 int max = obj[0].score, cnt = 0;33 for (int i = 0; i < MAXN; i++) {34 if (obj[i].score > max) {35 max = obj[i].score;36 cnt = i;37 }38 }39 cout << cnt << " " << max;40 return 0;41 }