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<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;
}
# | 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... |