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.
2 parents 2f864d5 + 4303046 commit 83ceb2fCopy full SHA for 83ceb2f
LiiNi-coder/202509/21 BOJ 줄세우기.md
@@ -0,0 +1,29 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
+ public static void main(String[] args) throws IOException {
7
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8
+ int n = Integer.parseInt(br.readLine());
9
+ int[] arr = new int[n];
10
+ for (int i = 0; i < n; i++) {
11
+ arr[i] = Integer.parseInt(br.readLine());
12
+ }
13
14
+ int[] dp = new int[n];
15
+ Arrays.fill(dp, 1);
16
+ int lis = 1;
17
18
19
+ for (int j = 0; j < i; j++) {
20
+ if (arr[j] < arr[i]) {
21
+ dp[i] = Math.max(dp[i], dp[j] + 1);
22
23
24
+ lis = Math.max(lis, dp[i]);
25
26
+ System.out.println(n - lis);
27
28
+}
29
+```
0 commit comments