HackerRank - Cracking the Code Interview - Binary Search: Ice Cream Parlor

Here's my Java solution for HackerRank and Cracking the Code Interview's Binary Search: Ice Cream Parlor problem.

import java.io.*;  
import java.util.*;  
import java.text.*;  
import java.math.*;  
import java.util.regex.*;

public class Solution {

    public static void work(int dollars, int[] costs, Map<Integer, Integer> flavors) {
        for (int i = 0; i < costs.length; i++) {
            int remainingNeeded = dollars - costs[i];
            if (flavors.containsKey(remainingNeeded)) {
                int i2 = flavors.get(remainingNeeded);
                System.out.println((i + 1) + " " + (i2 + 1));
                return;
            }
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for(int a0 = 0; a0 < t; a0++) {
            // Cost -> Flavor
            Map<Integer, Integer> map = new HashMap<Integer, Integer>();

            int m = in.nextInt();
            int n = in.nextInt();
            int a[] = new int[n];
            for(int a_i=0; a_i < n; a_i++){
                a[a_i] = in.nextInt();
                map.put(a[a_i], a_i);
            }

            work(m, a, map);
        }
    }
}