Skip to content

Instantly share code, notes, and snippets.

@parksangji
Created August 17, 2022 11:53
Show Gist options
  • Save parksangji/b157553d3587c51ac8fa7b338137c9e8 to your computer and use it in GitHub Desktop.
Save parksangji/b157553d3587c51ac8fa7b338137c9e8 to your computer and use it in GitHub Desktop.
package 그리디;
import java.util.*;
public class boj7076 {
static Scanner sc = new Scanner(System.in);
static int n;
static int [] dp;
static int solution(){
n = sc.nextInt();
dp = new int [n+1];
for(int i=0; i < n ; i++){
int tmp = sc.nextInt();
dp[tmp] = dp[tmp-1] + 1;
}
Arrays.sort(dp);
return n-dp[n];
}
public static void main(String[] args) throws Exception {
System.out.print(solution());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment