#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
884 KB |
Output is correct |
2 |
Correct |
0 ms |
884 KB |
Output is correct |
3 |
Correct |
0 ms |
884 KB |
Output is correct |
4 |
Correct |
0 ms |
884 KB |
Output is correct |
5 |
Correct |
0 ms |
884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
884 KB |
Output is correct |
2 |
Correct |
0 ms |
884 KB |
Output is correct |
3 |
Correct |
0 ms |
884 KB |
Output is correct |
4 |
Correct |
0 ms |
884 KB |
Output is correct |
5 |
Correct |
0 ms |
884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
928 KB |
Output is correct |
2 |
Correct |
0 ms |
928 KB |
Output is correct |
3 |
Correct |
2 ms |
984 KB |
Output is correct |
4 |
Correct |
2 ms |
984 KB |
Output is correct |
5 |
Correct |
1 ms |
988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1044 KB |
Output is correct |
2 |
Correct |
7 ms |
1276 KB |
Output is correct |
3 |
Correct |
15 ms |
1748 KB |
Output is correct |
4 |
Correct |
30 ms |
2684 KB |
Output is correct |
5 |
Correct |
72 ms |
4560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
6668 KB |
Output is correct |
2 |
Correct |
154 ms |
9012 KB |
Output is correct |
3 |
Correct |
188 ms |
10768 KB |
Output is correct |
4 |
Correct |
211 ms |
12528 KB |
Output is correct |
5 |
Correct |
217 ms |
12532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
212 ms |
12528 KB |
Output is correct |
2 |
Correct |
208 ms |
12532 KB |
Output is correct |
3 |
Correct |
219 ms |
12532 KB |
Output is correct |
4 |
Correct |
211 ms |
12524 KB |
Output is correct |
5 |
Correct |
207 ms |
12528 KB |
Output is correct |