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

题目链接在此。

#include

int main(){

    int N;
    scanf("%d",&N);

    int grades[100002] = {0};
    int id,grade;

    for(int i = 0; i < N; i++){
        scanf("%d %d",&id, &grade);
        grades[id] += grade;
    }

    int max = -1, max_index;
    for(int i = 0; i < 100002; i++){
        if(grades[i] > max){
            max = grades[i];
            max_index = i;
        }
    }

    printf("%d %d\n",max_index, grades[max_index]);

    return 0;
} 

你可能感兴趣的:(PAT,(Basic,Level),Practice)