Skip to content

Instantly share code, notes, and snippets.

@nullset2
Last active August 20, 2017 17:36
Show Gist options
  • Save nullset2/a983a64ae87ebf8fcef581f9e28ddc37 to your computer and use it in GitHub Desktop.
Save nullset2/a983a64ae87ebf8fcef581f9e28ddc37 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.*;
public class IceCreamParlor{
public static void main(String[] args) throws IOException {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine().trim());
for(int i=0; i<t; i++){
int m = Integer.parseInt(br.readLine().trim());
int n = Integer.parseInt(br.readLine().trim());
String[] fstr = br.readLine().trim().split(" ");
int[] flavors = new int[n];
for(int j=0; j<n; j++){
flavors[j] = Integer.parseInt(fstr[j]);
}
for(int j=0; j<n; j++){
for(int k=j+1;k<n;k++){
if(j<k && j!=k && flavors[j] + flavors[k] == m){
System.out.println(String.format("%d %d", j + 1, k + 1));
}
}
}
}
}catch(IOException e){
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment