挖掘机技术哪家强(20)

【思路】一个个比就是了,同一个学校的结果相加。数组大小为100001
import java.util.*;
public class Main{
    public static void main(String[] args){
        int[] num = new int[100001];//遇到编号为100000的
        int n, x, y;
        int max =0;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i=0; i<n; i++){
            x = sc.nextInt();
            y = sc.nextInt();
            num[x]+=y;
            if(num[x] > num[max]){
                max = x;
            }
                
        }
        
        System.out.printf("%d %d", max, num[max]);
    }
}


全部评论

相关推荐

刘湘_passion:太强了牛肉哥有被激励到
点赞 评论 收藏
分享
喜欢喜欢喜欢:这是我见过最长最臭的简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务