挖掘机技术哪家强(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]); } }