The lead game..can some one point out the mistake.

Problem link - http://www.codechef.com/problems/TLG

Solution-

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.SortedSet;
import java.util.TreeSet;

public class TheLeadGame {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(
				new OutputStreamWriter(System.out)));
		int num = Integer.parseInt(br.readLine());
		SortedSet<Integer> pl1 = new TreeSet<Integer>();
		SortedSet<Integer> pl2 = new TreeSet<Integer>();
		while (num-- > 0) {
			String strr[] = br.readLine().split(" ");
			if (Integer.parseInt(strr[0]) > Integer.parseInt(strr[1])) {
				pl1.add((Integer.parseInt(strr[0])) - Integer.parseInt(strr[1]));
			} else {
				pl2.add((Integer.parseInt(strr[1])) - Integer.parseInt(strr[0]));
			}
		}
		if (pl1.last() > pl2.last()) {
			pw.println(1 + " " + pl1.last());
		} else {
			pw.println(2 + " " + pl2.last());
		}
		pw.close();
	}
}

can we have an aligned code please!

@hell_yeah : Go to MySubmissions page from the problem page . Then click on View for the submission you want to be reviewed and then copy the link of that page from the browser and paste it here on the forum .
That way we will be able to see aligned code .

1 Like

http://www.codechef.com/viewsolution/3928112 please review my solution . It is giving correct answer. But showing wrong answer

@prudvinit you are considering only individual round scores of two players, instead of that you have to consider the score up to that round for both players and update the maximum.for more clarity observe the two tables given in the problem. add the scores of player one and player two up to that round(for which round ur calculating) and take their diff and now compare diff