I am getting RuntimeError while executing this code but I am getting all 
test cases passed in my local ide. Can anyone help me know what is wrong in 
this code?

import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(new BufferedReader(new 
InputStreamReader(System.in)));
int T = sc.nextInt();
for(int i = 0;i < T;i++)  {
int N = sc.nextInt();
Map<Integer, List<Integer>> map = new TreeMap<Integer, List<Integer>>();
for(int j = 0;j< N;j++)  {
map.put(sc.nextInt(), Arrays.asList(sc.nextInt(),(j+1)));  //stores 
(starting,[ending,Activity number])
}
//System.out.println(map);
String s = "";
int C = 0;
int J = 0;
boolean cam = false;
boolean jam = true;
for(int start : map.keySet())  {
if(cam)  {
if(start >= C)  {
cam = false;
}
}
if(jam)  {
if(start >= J)  {
jam = false;
}
}
if(!cam)  {
s = s + "C";
C = (map.get(start)).get(0);
cam = true;
}
else if(!jam)  {
s = s + "J";
J = (map.get(start)).get(0);
jam = true;
}
else if(cam && jam)  {
s = "IMPOSSIBLE";
continue;
}
}
String result = new String();
if(s == "IMPOSSIBLE")  {
System.out.println("Case #"+(i+1)+": "+s);
}
else  {
for(Map.Entry<Integer, List<Integer>> entry : map.entrySet())  {
result = result + 
Character.toString((s.charAt((entry.getValue()).get(1)-1)));
}
System.out.println("Case #"+(i+1)+": "+result);
}
}
sc.close();

}
}

Output in my local ide  :

4
3
360 480
420 540
600 660
Case #1: CJC
3
0 1440
1 3
2 4
Case #2: IMPOSSIBLE
5
99 150
1 100
100 301
2 5
150 250
Case #3: JCCJJ
2
0 720
720
1440
Case #4: CC

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/8118e79d-fe75-4e46-8e4a-0411bc69984a%40googlegroups.com.

Reply via email to