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