Google Code Jam: Store Credit Java Solution It would be great if I could get this code reviewed.
I would love tips on how I could improve my code.

Problem
You receive a credit C at a local store and would like to buy two items. You first walk through the store and create a list L of all available items. From this list you would like to buy two items that add up to the entire value of the credit. The solution you provide will consist of the two integers indicating the positions of the items in your list (smaller number first).
Input
The first line of input gives the number of cases, N. N test cases follow. For each test case there will be:
One line containing the value C, the amount of credit you have at the store.
One line containing the value I, the number of items in the store.
One line containing a space separated list of I integers. Each integer P
indicates the price of an item in the store.
Each test case will have exactly one solution.
Output
For each test case, output one line containing &quot;Case #x: &quot; followed by the indices of the two items whose price adds up to the store credit. The lower index should be output first.

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.stream.IntStream;

public class StoreCredit {

    private static int case_num = 0;
    private static int num_cases, credit_value, item_cnt;
    private static ArrayList&lt;Integer&gt; prices;
    private static Scanner reader;
    private static ArrayList&lt;String&gt; output;    

    public static void main(String... args) throws FileNotFoundException{
        output = new ArrayList&lt;String&gt;();
        reader = new Scanner(new File(&quot;src/store_credit/input.txt&quot;));
    
        num_cases = reader.nextInt();
        for(int i = 0; i &lt; num_cases; ++i){
            prices = new ArrayList&lt;Integer&gt;();
            credit_value = reader.nextInt();
            item_cnt = reader.nextInt();
            IntStream.range(0, item_cnt).forEach((j) -&gt;  prices.add(j, reader.nextInt()));
            solution();
        
        }
        for(String s : output)
            System.out.println(s);
    }

    public static void solution(){
        for(int i = 0; i &lt; item_cnt; ++i){
            if(prices.contains(credit_value - prices.get(i))){
                output.add(&quot;Case #&quot; + ++case_num + &quot;: &quot; + (i + 1) + &quot; &quot; + (prices.lastIndexOf(credit_value-prices.get(i)) + 1));
                return;
            }
        }
    }
}

Input Information
Performance is bad. List.contains() runs in linear time, driving it to quadratic. Recommendation: prepare the list of {price, index} pairs, and stable sort it by prices. The solution is then found in a single scan, along the lines of

    while (head &lt; tail) {
        total = head-&gt;price + tail-&gt;price;
        if (total &lt; credit) {
            ++head;
        else if total &gt; credit) {
            --tail;
        else {
            return {head-&gt;index, tail-&gt;index};
        }
    }