#include<stdio.h>
int n, m[1000002];
int p[1000002];
int dy[1000002];
int max;
int input()
{
int i;
scanf("%d",&n);
for(i=1 ; i<=n ; i++)
{
scanf("%d",&m[i]);
p[m[i]]=i;
}
return 0;
}
int process()
{
int i;
for(i=1 ; i<=n ; i++)
{
dy[i]=1;
if(p[i-1]<p[i] && dy[i]<dy[i-1]+1)
{
dy[i]=dy[i-1]+1;
}
if(max<dy[i])
{
max=dy[i];
}
}
return 0;
}
int output()
{
printf("%d",n-max);
return 0;
}
int main()
{
input();
process();
output();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
12804 KB |
Output is correct |
2 |
Correct |
0 ms |
12804 KB |
Output is correct |
3 |
Correct |
0 ms |
12804 KB |
Output is correct |
4 |
Correct |
0 ms |
12804 KB |
Output is correct |
5 |
Correct |
0 ms |
12804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
12804 KB |
Output is correct |
2 |
Correct |
0 ms |
12804 KB |
Output is correct |
3 |
Correct |
0 ms |
12804 KB |
Output is correct |
4 |
Correct |
0 ms |
12804 KB |
Output is correct |
5 |
Correct |
0 ms |
12804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
12804 KB |
Output is correct |
2 |
Correct |
0 ms |
12804 KB |
Output is correct |
3 |
Correct |
0 ms |
12804 KB |
Output is correct |
4 |
Correct |
0 ms |
12804 KB |
Output is correct |
5 |
Correct |
0 ms |
12804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
12804 KB |
Output is correct |
2 |
Correct |
4 ms |
12804 KB |
Output is correct |
3 |
Correct |
12 ms |
12804 KB |
Output is correct |
4 |
Correct |
28 ms |
12804 KB |
Output is correct |
5 |
Correct |
52 ms |
12804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
12804 KB |
Output is correct |
2 |
Correct |
120 ms |
12804 KB |
Output is correct |
3 |
Correct |
140 ms |
12804 KB |
Output is correct |
4 |
Correct |
176 ms |
12804 KB |
Output is correct |
5 |
Correct |
132 ms |
12804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
172 ms |
12804 KB |
Output is correct |
2 |
Correct |
160 ms |
12804 KB |
Output is correct |
3 |
Correct |
168 ms |
12804 KB |
Output is correct |
4 |
Correct |
176 ms |
12804 KB |
Output is correct |
5 |
Correct |
172 ms |
12804 KB |
Output is correct |