-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj1940.java
More file actions
56 lines (43 loc) · 1.32 KB
/
Copy pathboj1940.java
File metadata and controls
56 lines (43 loc) · 1.32 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package Algo;
import java.util.*;
import java.io.*;
class Jumong {
static int start_idx = 0;
static int end_idx = 0;
static int count = 0;
static int[] optionArr;
static int printCount(int comp) {
// System.out.println(Arrays.toString(optionArr));
while (start_idx < end_idx) {
if(comp > optionArr[start_idx] + optionArr[end_idx]) {
start_idx++;
} else if (comp < optionArr[start_idx] + optionArr[end_idx]) {
end_idx--;
} else {
// System.out.println("start_idx : " + start_idx + " end_idx : " + end_idx);
count++;
start_idx++;
end_idx--;
}
}
return count;
}
}
public class boj1940{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.valueOf(st.nextToken());
st = new StringTokenizer(br.readLine());
int m = Integer.valueOf(st.nextToken());
st = new StringTokenizer(br.readLine());
int[] intArr = new int[N];
for(int i = 0; i<N; i++) {
intArr[i] = Integer.parseInt(st.nextToken());
}
Jumong.optionArr = intArr;
Jumong.end_idx = N-1;
Arrays.sort(Jumong.optionArr);
System.out.println(Jumong.printCount(m));
}
}