I have coded the Below program for Store Credit - GCJ 2010 (Africa) Problem
Problem Description link:http://code.google.com/codejam/contest/351101/ dashboard#s=p0 import java.io.IOException; import java.io.FileReader; import java.io.BufferedReader; import java.util.*; public class Test { public static void main(String arg[]) throws IOException{ String text; FileReader fr=new FileReader("E:/test.txt"); BufferedReader br=new BufferedReader(fr); int l=Integer.parseInt(br.readLine()); l=l*3; String []size=new String[l]; ArrayList<String> ar=new ArrayList<String>(); for(int i=0;i<l;i++){ ar.add(br.readLine()); } int arr; int caase,sum,index1,index2; caase=index1=index2=0; String[] items; int itemss[]; for(int j=0;j<l;j++){ sum=Integer.parseInt((ar.get(j)).trim()); arr=Integer.parseInt((ar.get(++j)).trim()); items=ar.get(++j).split(" "); itemss=new int[arr]; for(int i=0;i<arr;i++) { itemss[i]=Integer.parseInt(items[i]); } for(int a=0;a<arr;a++){ for(int b=0;b<arr;b++){ if(a!=b){ if((itemss[a]+itemss[b])==sum){ index1=a+1;index2=b+1; } } } } caase=caase+1; System.out.println("case#"+caase+":"+index1+" "+index2); } } } Here Test.txt is the input file with test cases. Please advise as how can LOC(lines of code) for the solution coded above can be minimized and performance can be increased for the same. -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
