File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
weekly/week02/BOJ_1965_상자넣기 Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .io .BufferedReader ;
2+ import java .io .IOException ;
3+ import java .io .InputStreamReader ;
4+
5+ // 상자 넣기
6+ // 알고리즘 종류 확인
7+ public class BOJ_1965 {
8+
9+ public static void main (String [] args ) throws IOException {
10+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
11+
12+ int N = Integer .parseInt (br .readLine ());
13+
14+ int [] arr = new int [N +1 ];
15+ String [] s = br .readLine ().split (" " );
16+ int [] dp = new int [N +1 ];
17+
18+ for (int i =1 ; i <=N ; i ++){
19+ arr [i ] = Integer .parseInt (s [i -1 ]);
20+ dp [i ] = 1 ;
21+ }
22+
23+ for (int i =2 ; i <=N ; i ++){
24+ for (int j =1 ; j <i ; j ++){
25+ if (arr [i ] > arr [j ]){
26+ dp [i ] = Math .max (dp [j ]+1 , dp [i ]);
27+ }
28+ }
29+ }
30+
31+ int max = 0 ;
32+ for (int i =1 ; i <=N ; i ++){
33+ if (max < dp [i ]){
34+ max = dp [i ];
35+ }
36+ }
37+
38+ System .out .println (max );
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments