Hi,all. Looking at this task, please!

The program committee must be able to correctly estimate the level of teams that will participate in the forthcoming contest and choose the problems according to that level. It is not always easy to prepare a problem set that will please both school teams and the most experienced veterans of the programming contests, who won dozens of them.
In order to make his job easier, the chairman of the program committee asked the chairman of the jury to make the eligibility rules stricter and forbid too young or too experienced teams to participate in the contest.
For each team that had applied for participation, the jury calculated the average age of its members and the number of official contests this team participated in. In addition, the program committee estimated the satisfaction that each team would get from the problem set.
The jury decided to state the eligibility rules as follows: a team is eligible to participate if and only if its average age and the number of contests it participated in fall in certain ranges of values. It only remained to set the boundaries of these ranges so that the sum of satisfactions of the eligible teams would be as large as possible. Of course, there had to be at least two eligible teams, otherwise there would have been no sense in holding the contest.

The first line contains the number n of teams that want to participate in the contest (2 ≤ n ≤ 1500). Each of the following n lines contains three space-separated integers a, f and s (4108 ≤ a ≤ 109; 0 ≤ f, |s| ≤ 109). They are the average age of participants (in seconds), the number of official contests the team participated in, and the satisfaction that the team will get from the problem set, respectively.
In the first line output the minimal and maximal admissible average age of participants. In the second line output the minimal and maximal admissible number of contests. All these numbers must be nonnegative integers and must not exceed 109. If there are several possible answers, output any of them.


500000000 1 1
510000000 3 -10
600000000 3 2
700000000 4 3

550000000 750000000
2 5

That's source http://acm.timus.ru/problem.aspx?spa...1717&locale=en

My beginning code
import java.io.*;

public class elig {

	 * @param args
	public static void main(String[] args)throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br =
			      new BufferedReader(
			        new InputStreamReader(System.in));
		int n = 0, a = 0, f = 0, s = 0;
			    System.out.print(">> Введите n (2 <= n <= 1500): ");
			   n = Integer.parseInt(br.readLine());
			    while ((n<2) || (n>1500));
				for (int i=0; i<n;i++)
			    System.out.print(">> Введите a (410^8 <= a <= 10^9): ");
			   a = Integer.parseInt(br.readLine());
			    while ((a<4*Math.pow(10, 8)) || (a>Math.pow(10, 9))); 
			    System.out.print(">> Введите f (f >= 0): ");
			   f = Integer.parseInt(br.readLine());
			    while (f<0);
			    System.out.print(">> Введите s (|s| <= 10^9): ");
			   s = Integer.parseInt(br.readLine());
			    while (Math.abs(s)>Math.pow(10, 9)); 

I don't undestand what we must to do. And I don't know how we receive output. Help me to solve this problem, please.