CodeChef submission 59580 (JAVA) plaintext list. Status: RE, problem PAIRSUM, contest . By triplem (Stephen Merriman), 2009-07-26 05:18:38.
import java.io.IOException; import java.util.*; public class Main { public int array_Size = 0; public int [] number_array; public void computeGoodArray() { Hashtable<Integer, List> pairMap = new Hashtable<Integer, List>(); Hashtable<Integer, List> pairMapFirstIndex = new Hashtable<Integer, List>(); List<Integer> pairList = new ArrayList<Integer>(); int maxSet = 0; int lastPairSum = -999; for (int i=0; i < this.array_Size - 1; i++) { for (int j=i+1; j < this.array_Size; j++) { int pairSum = number_array[i] + number_array[j]; List<Integer> firstIndexList = new ArrayList<Integer>(); List<Integer> secondIndexList = new ArrayList<Integer>(); if (!pairList.contains(pairSum)) { pairList.add(pairSum); firstIndexList.add(i); secondIndexList.add(j); pairMap.put(pairSum, secondIndexList); pairMapFirstIndex.put(pairSum, firstIndexList); } else { if (!secondIndexList.contains(j) && !firstIndexList.contains(i)) { firstIndexList.add(i); secondIndexList.add(j); firstIndexList); intersection.retainAll(secondIndexList); if (intersection.size() == 0) { pairMap.put(pairSum, secondIndexList); pairMapFirstIndex.put(pairSum, firstIndexList); } else { } } } lastPairSum = pairSum; } lastPairSum = -999; } Iterator<Integer> itr = pairList.iterator(); while (itr.hasNext()) { if ( pairsVal.size() > maxSet) { maxSet = pairsVal.size(); } } } Main obj = new Main(); String input = ""; try{ obj.number_array = new int[obj.array_Size]; input = r.readLine().trim(); while (input.trim().length()==0) input = r.readLine(); numbers = input.split(" "); for (int i=0; i < obj.array_Size; i++) { } e.printStackTrace(); } obj.computeGoodArray(); } }
Comments

