Who is the strongest female man (java)

Who is the strongest female man

Time Limit: 1000 ms  Memory Limit: 65536 KiB

Problem Description

As we all know, the annual Women's Man contest is coming again. Due to the popularity of female men recently, the number of people participating in the women's competition has become very large. So the tournament team came to you and asked you to write a program to find out who is the strongest female man. Everyone knows that the less beautiful a girl is, the easier it is to become a female man (how can a beautiful one become a man?), and the more powerful a girl is, the more she becomes a female man (after all, a female man is still more powerful). So we give the female man two attributes, one is the beauty value x, and the other is the strength value y. Of course, the larger the value of x is, the more beautiful the girl is. Now I want you to find out how many ugliest girls there are and what their strengths are.

Input

 Enter a T first, which means there are T individuals (T<10000)
Next T lines, each line has two numbers x, y, representing the beauty value and strength value of this female man respectively (x, y<2*10^9)

Output

 Output a line with two numbers representing the number of ugliest girls and their power sum.

Sample Input

5
1 1
2 2
1 4
2 10
10 100

Sample Output

2 5
The data is a bit large, and the variable must be defined with the long type when summing.
 
  
//package hello;

import java.util. *;


public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt ();
		int[] x = new int[11000] ;
		int[] y = new int[11000] ;
		for(int i=0;i<n;i++){
			x [i] = cin.nextInt ();
			y[i] = cin.nextInt() ;
		}
		int min = x[0] ; 
		long sum = 0 ; 
		for(int i=0;i<n;i++){
			if(min>x[i]){
				min = x[i] ; 
			}
		}
		int num = 0 ; 
		for(int i=0;i<n;i++){
			if(x[i]==min){
				num++;
				sum = sum + y[i] ; 
			}
		}
		System.out.println(num+" "+sum);
	}

}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325735822&siteId=291194637