We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b601a4a commit 252b4bcCopy full SHA for 252b4bc
JHLEE325/202508/16 BOJ G4 줄세우기.md
@@ -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
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