谁是最强的女汉子
Time Limit: 1000 ms
Memory Limit: 65536 KiB
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
Hint
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long [] x = new long[n];
long [] y = new long[n];
for(int i = 0; i < n; i++) {
x[i] = sc.nextLong();
y[i] = sc.nextLong();
}
Girl W = new Girl();
W.beauty(n, x, y);
sc.close();
}
}
class Girl {
public void beauty(int n, long[] x, long[] y) {
long count = 0, min, sum = 0;
min = x[0];
for(int i = 0; i < n; i++) {
if(x[i] <= min) {
if(x[i] < min) {
min = x[i];
}
}
}
for(int i = 0; i < n; i++) {
if(x[i] == min) {
count++;
sum += y[i];
}
}
System.out.println(count +" " + sum);
}
}