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:%dn", 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;
}
内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!

相关课程

7285 0元 45元 限免