//1032 挖掘机技术哪家强

//1032	挖掘机技术哪家强
//算法笔记P87 代码不同
#include <iostream>
#define maxSize 100001
using namespace std;
int main(){
    unsigned int scores[maxSize] = {};
    int n,schoolID,score,max=0,flag = 0;
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>schoolID>>score;
        scores[schoolID] += score;
    }
    for(int i=1;i<=n;++i){
        if(max < scores[i]){
            max = scores[i];
            flag = i;
        }
    }
    cout<<flag<<" "<<scores[flag]<<endl;
    return 0;
}

/**
 * int a[1000]; //所有元素都是未知值
 * int a[1000] = {1};//第一个元素为1,其余元素都是0
 * int a[1000] = {}; //所有元素都会初始化为0
*/

全部评论

相关推荐

04-29 22:35
门头沟学院 Java
牛友说改了名字能收到offer:旧图新发查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务