-
-
Save parksangji/b157553d3587c51ac8fa7b338137c9e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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