File tree 1 file changed +56
-0
lines changed
1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ package Algo ;
2
+
3
+ import java .util .*;
4
+ import java .io .*;
5
+
6
+ class Jumong {
7
+ static int start_idx = 0 ;
8
+ static int end_idx = 0 ;
9
+ static int count = 0 ;
10
+ static int [] optionArr ;
11
+
12
+ static int printCount (int comp ) {
13
+ // System.out.println(Arrays.toString(optionArr));
14
+ while (start_idx < end_idx ) {
15
+ if (comp > optionArr [start_idx ] + optionArr [end_idx ]) {
16
+ start_idx ++;
17
+ } else if (comp < optionArr [start_idx ] + optionArr [end_idx ]) {
18
+ end_idx --;
19
+ } else {
20
+ // System.out.println("start_idx : " + start_idx + " end_idx : " + end_idx);
21
+ count ++;
22
+ start_idx ++;
23
+ end_idx --;
24
+ }
25
+ }
26
+ return count ;
27
+ }
28
+ }
29
+
30
+ public class boj1940 {
31
+ public static void main (String [] args ) throws IOException {
32
+
33
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
34
+ StringTokenizer st = new StringTokenizer (br .readLine ());
35
+
36
+ int N = Integer .valueOf (st .nextToken ());
37
+
38
+
39
+ st = new StringTokenizer (br .readLine ());
40
+ int m = Integer .valueOf (st .nextToken ());
41
+
42
+ st = new StringTokenizer (br .readLine ());
43
+ int [] intArr = new int [N ];
44
+
45
+ for (int i = 0 ; i <N ; i ++) {
46
+ intArr [i ] = Integer .parseInt (st .nextToken ());
47
+ }
48
+ Jumong .optionArr = intArr ;
49
+ Jumong .end_idx = N -1 ;
50
+ Arrays .sort (Jumong .optionArr );
51
+
52
+ System .out .println (Jumong .printCount (m ));
53
+
54
+
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments