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

原题: https://www.patest.cn/contests/pat-b-practise/1032

思路: 开个100K+的数组, 轻松搞定.

完整实现:

#include <stdio.h>

int main (void) {
    int n;
    int stu[100001] = {0};
    int no;
    int score;
    int maxNo;
    int maxScore = 0;
    int i;

    scanf("%d", &n);
    for (i=1; i<=n; i++) {
        scanf("%d %d", &no, &score);
        stu[no] += score;
        if (stu[no] > maxScore) {
            maxScore = stu[no];
            maxNo = no;
        }
    }
    printf("%d %d
", maxNo, maxScore);

    return 0;
}
原文地址:https://www.cnblogs.com/asheng2016/p/7823141.html