File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed
Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 2020 KB, 시간: 4 ms
7+ 메모리: 16432 KB, 시간: 168 ms
88
99### 분류
1010
1111정렬, 두 포인터
1212
1313### 제출 일자
1414
15- 2024년 5월 11일 20:39:15
15+ 2025년 9월 17일 22:38:40
1616
1717### 문제 설명
1818
Original file line number Diff line number Diff line change 1+ import java .io .*;
2+ import java .util .*;
3+
4+ public class Main {
5+ public static void main (String [] args ) throws IOException {
6+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
7+
8+ int N = Integer .parseInt (br .readLine ());
9+ int M = Integer .parseInt (br .readLine ());
10+ int [] A = new int [N ];
11+
12+ StringTokenizer st = new StringTokenizer (br .readLine ());
13+
14+ for (int i =0 ; i <N ; i ++){
15+ A [i ] = Integer .parseInt (st .nextToken ());
16+ }
17+
18+ Arrays .sort (A );
19+
20+ int start = 0 ;
21+ int end = N -1 ;
22+ int count = 0 ;
23+
24+ while (start < end ){
25+ if (A [start ] + A [end ] < M ) {
26+ start ++;
27+ }
28+ else if (A [start ] + A [end ] > M ){
29+ end --;
30+ }
31+ else {
32+ count ++;
33+ start ++;
34+ end --;
35+ }
36+ }
37+
38+ System .out .println (count );
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments