-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumOfTwoNumbers.java
More file actions
30 lines (28 loc) · 1.07 KB
/
SumOfTwoNumbers.java
File metadata and controls
30 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
public class SumOfTwoNumbers {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
long x = Long.parseLong(st.nextToken());
st = new StringTokenizer(br.readLine());
HashMap<Long,Integer> map= new HashMap<>();
boolean f1 = false;
for(int i=0;i<n;i++) {
long a = Long.parseLong(st.nextToken());
if (map.containsKey(x - a)) {
System.out.println((map.get(x - a) + 1) + " " + (i + 1));
f1 = true;
break;
}
map.put(a, i);
}
if(!f1){
System.out.println("IMPOSSIBLE");
}
}
}