Problem Description
众所周知,一年一度的女汉子大赛又来啦。由于最近女汉子比较流行,所以参加女汉子比赛的人数变得很多很多。所以赛事组找来了你,让你写一个程序找出谁是最强的女汉子。大家都知道,越是不漂亮的女生就越容易成为女汉子(漂亮的怎么会成为汉子?),而越是力量大的女生也越成为女汉子(毕竟女汉子还是比较有力量的)。所以我们就给女汉子两个属性,一个是漂亮值x,一个是力量值y。当然x的值越大,就代表这个女生就越漂亮,现在想让你求出来最丑的女孩有多少个,她们的力量和是多少。
Input
先输入一个T,代表有T个人(T<10000)
接下来T行,每行有两个数字x,y,分别代表这个女汉子的漂亮值和力量值(x,y<2*10^9)
Output
输出一行,有两个数字,分别代表最丑的女孩的数量,和她们的力量和。
Sample Input
5 1 1 2 2 1 4 2 10 10 100
Sample Output
2 5
import java.util.Scanner;
class Girl{
long x, y;
public Girl(long x, long y) {
this.x = x;
this.y = y;
}
}
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int n = reader.nextInt();
Girl g[] = new Girl[10900];
long min = 10000, sum=0, num=0;
for(int i=0; i<n; i++) {
int a= reader.nextInt();
g[i] = new Girl(a, reader.nextLong());
if(min>a) {
min = a;
}
}
for(int i=0; i<n; i++) {
if(g[i].x==min) {
sum+=g[i].y;
num++;
}
}
System.out.println(num+" "+sum);
}
}