This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
int main(){
int n;scanf("%d",&n);
int a[n];
int inv[n];
for(int i=0;i<n;i++){scanf("%d",a+i);inv[a[i]]=i;}
int dp[n+1];
dp[1]=1;
int ans=1;
for(int i=2;i<n;i++){
if(inv[i]>inv[i-1])dp[i]=dp[i-1]+1;
else dp[i]=1;
if(ans<dp[i])ans=dp[i];
}
printf("%d",n-ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |