谁是最强的女汉子
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
Source
zhaopeng
import java.util.*;
class men {
long x;
long y;
public men(long xx, long yy) {
x = xx;
y = yy;
}
}
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
long sum=0,num=0,max=0x3f3f3f;
men a[] = new men[n];
for (int i = 0; i < n; i++) {
a[i] = new men(cin.nextLong(), cin.nextLong());
}
for(int i=0;i<n;i++)
{
if (max > a[i].x)
max = a[i].x;
}
for(int i=0;i<n;i++)
if(a[i].x==max)
{sum+=a[i].y;num++;}
System.out.println(num+" "+sum);
cin.close();
}
}