标签:int 编号 最大 pac 初始 pre color 代码 成绩
AC代码
#include <cstdio>
#include <algorithm>
using namespace std;
const int max_n = 110000; //题目让给不超过10^5的正整数
struct School {
int score;
} school[max_n];
void init() { //初始化各个学校成绩
for(int i = 0; i < max_n; i++) {
school[i].score = 0;
}
}
int main() {
void();
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
int n = 0, biggest = 0; //n为参赛人数, biggest为参赛最大学校编号
int MAX_num = -1, MAX = -1; //a为总得分最高的编号, b为总得分最高的总分
scanf("%d", &n);
for(int i = 0; i < n; i++) {
int no = 0, score = 0;
scanf("%d%d", &no, &score);
school[no].score += score;
//int da = max(no, biggest);
//biggest = da;
}
for (int i = 0; i < max_n; i++) {
/*if(school[i].score != 0) {
printf("schID:%d schScore:%d\n", i, school[i].score);
}
*/
if(school[i].score != 0) {
if(school[i].score > MAX) {
MAX = school[i].score;
MAX_num = i;
}
}
}
printf("%d %d", MAX_num, MAX);
return 0;
}
标签:int 编号 最大 pac 初始 pre color 代码 成绩
原文地址:https://www.cnblogs.com/isChenJY/p/11265210.html