谁是最强的女汉子

import java.util.*;
public class Main {

public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int a[] = new int[10010];
	int b[] = new int[10010];
	int n,i,j,t;
	n = in.nextInt();
	for(i = 0; i< n;i++){
		a[i] = in.nextInt();
		b[i] = in.nextInt();
	}
	for(i = 0; i <= n -2;i++){
	for(j = 0;j <= n-2-i;j++){
		if(a[j] == a[j+1]){
			if(b[j]> b[j+1]){
				t = a[j];
				a[j] = a[j+1];
				a[j+1] = t;
				t = b[j];
				b[j] = b[j+1];
				b[j+1] = t;
			}
		}
		if(a[j] > a[j+1]){
			t = a[j];
			a[j] = a[j+1];
			a[j+1] = t;
			t = b[j];
			b[j] = b[j+1];
			b[j+1] = t;
		}
	}
	}
	int sum1 = 1;long sum2 = b[0];
	for(i = 1; i < n;i++){
		if(a[0] == a[i]){
			sum1++;
			sum2 =sum2+ b[i];
		}
	}
	System.out.println(sum1 +" "+sum2);

}

}

猜你喜欢

转载自blog.csdn.net/weixin_43490695/article/details/84063398
今日推荐