PAT B1042 挖掘机哪家强

Posted ischenjy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT B1042 挖掘机哪家强相关的知识,希望对你有一定的参考价值。

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;

以上是关于PAT B1042 挖掘机哪家强的主要内容,如果未能解决你的问题,请参考以下文章

PAT乙级 1032. 挖掘机技术哪家强(20)

PAT 1032 挖掘机技术哪家强

PAT-乙级-1032 挖掘机技术哪家强

[PAT乙级]1032 挖掘机技术哪家强

PAT乙级 1032 挖掘机技术哪家强 (20 分)

PAT 1032 挖掘机技术哪家强