Skip to content

Commit 252b4bc

Browse files
authored
[20250816] BOJ / G4 / 줄세우기 / 이준희
1 parent b601a4a commit 252b4bc

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
public static void main(String[] args) throws Exception {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
int n = Integer.parseInt(br.readLine());
9+
10+
int[] arr = new int[n];
11+
for (int i = 0; i < n; i++) {
12+
arr[i] = Integer.parseInt(br.readLine());
13+
}
14+
15+
int[] dp = new int[n];
16+
Arrays.fill(dp, 1);
17+
18+
int lis = 1;
19+
for (int i = 0; i < n; i++) {
20+
for (int j = 0; j < i; j++) {
21+
if (arr[j] < arr[i]) {
22+
dp[i] = Math.max(dp[i], dp[j] + 1);
23+
}
24+
}
25+
lis = Math.max(lis, dp[i]);
26+
}
27+
28+
System.out.println(n - lis);
29+
}
30+
}
31+
32+
```

0 commit comments

Comments
 (0)