This is a probable solution to CODE JAM's Store Credit.
import java.util.HashSet;See you later friends.
import java.util.Scanner;
import java.util.Set;
public class StoreCredit {
public static void main(String[] args) {
try {
Scanner scanner = new Scanner(ReverseWords.class.getClassLoader().getResourceAsStream("A-large-practice.in"));
int problemCount = Integer.parseInt(scanner.nextLine());
int caseCounter = 1;
for(int iProblemCounter = 0; iProblemCounter < problemCount; iProblemCounter++) {
SetcompletedIndexes = new HashSet ();
int creditAmount = Integer.parseInt(scanner.nextLine());
int numberOfItems = Integer.parseInt(scanner.nextLine());
String itemsLine = scanner.nextLine();
String[] intArray = itemsLine.split(" ");
String output = "";
itemLoop:{
for (int iArrayCounter = 0; iArrayCounter < numberOfItems; iArrayCounter++) {
completedIndexes.add(iArrayCounter);
for (int iArrayInnerCounter = 0; iArrayInnerCounter < numberOfItems; iArrayInnerCounter++) {
if(completedIndexes.contains(iArrayInnerCounter)) {
continue;
}
int sum = (Integer.parseInt(intArray[iArrayCounter]) + Integer.parseInt(intArray[iArrayInnerCounter]));
output = (iArrayCounter + 1) + " " + (iArrayInnerCounter + 1);
if(sum == creditAmount) {
break itemLoop;
}
}
}
}
System.out.println("Case #" + (caseCounter++) + ": " + output);
}
} catch (Throwable a_th) {
a_th.printStackTrace();
}
}
}