File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed
백준/Silver/16139. 인간-컴퓨터 상호작용 Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 15272 KB, 시간: 152 ms
7+ 메모리: 105588 KB, 시간: 664 ms
88
99### 분류
1010
1111누적 합
1212
1313### 제출 일자
1414
15- 2024년 12월 2일 17:38:17
15+ 2024년 12월 2일 17:47:07
1616
1717### 문제 설명
1818
Original file line number Diff line number Diff line change @@ -9,14 +9,13 @@ public static void main(String[] args) throws IOException {
99
1010 int question = Integer .parseInt (br .readLine ());
1111
12- int check [][] = new int [26 ][2001 ];
12+ int check [][] = new int [26 ][S . length ()+ 1 ];
1313
1414 for (int i =0 ; i <S .length (); i ++) {
15- char currentChar = S .charAt (i );
16-
17- for (int j = i ; j <S .length (); j ++) {
18- check [currentChar -'a' ][j ]++;
15+ for (int j = 0 ; j <26 ; j ++) {
16+ check [j ][i +1 ] = check [j ][i ];
1917 }
18+ check [S .charAt (i )-'a' ][i +1 ]++;
2019 }
2120
2221 StringBuilder sb = new StringBuilder ();
@@ -28,12 +27,8 @@ public static void main(String[] args) throws IOException {
2827
2928 int l = Integer .parseInt (st .nextToken ());
3029 int r = Integer .parseInt (st .nextToken ());
31- if (l ==0 ) {
32- sb .append (check [a -'a' ][r ]).append ("\n " );
3330
34- }
35- else
36- sb .append (check [a -'a' ][r ] - check [a -'a' ][l -1 ]).append ("\n " );
31+ sb .append (check [a -'a' ][r +1 ] - check [a -'a' ][l ]).append ("\n " );
3732
3833 }
3934 System .out .println (sb );
You can’t perform that action at this time.
0 commit comments