#include <cstdio>
int a[1000001];
int main() {
int N, i, max = -1, cnt = 0;
int last = -1;
scanf("%d", &N);
for (i=1; i<=N; ++i) {
int j;
scanf("%d", &j);
a[j] = i;
}
for (i=1; i<=N; ++i) {
if (last < a[i]) {
++cnt;
} else {
if (max < cnt) {
max = cnt;
}
cnt = 0;
}
last = a[i];
}
printf("%d\n", N - max - 1);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4992 KB |
Output is correct |
2 |
Correct |
0 ms |
4992 KB |
Output is correct |
3 |
Correct |
0 ms |
4992 KB |
Output is correct |
4 |
Correct |
0 ms |
4992 KB |
Output is correct |
5 |
Correct |
0 ms |
4992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4992 KB |
Output is correct |
2 |
Correct |
0 ms |
4992 KB |
Output is correct |
3 |
Correct |
0 ms |
4992 KB |
Output is correct |
4 |
Correct |
0 ms |
4992 KB |
Output is correct |
5 |
Correct |
0 ms |
4992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4992 KB |
Output is correct |
2 |
Correct |
0 ms |
4992 KB |
Output is correct |
3 |
Correct |
0 ms |
4992 KB |
Output is correct |
4 |
Correct |
0 ms |
4992 KB |
Output is correct |
5 |
Correct |
0 ms |
4992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4992 KB |
Output is correct |
2 |
Correct |
4 ms |
4992 KB |
Output is correct |
3 |
Correct |
12 ms |
4992 KB |
Output is correct |
4 |
Correct |
24 ms |
4992 KB |
Output is correct |
5 |
Correct |
52 ms |
4992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
4992 KB |
Output is correct |
2 |
Correct |
112 ms |
4992 KB |
Output is correct |
3 |
Correct |
132 ms |
4992 KB |
Output is correct |
4 |
Correct |
168 ms |
4992 KB |
Output is correct |
5 |
Correct |
168 ms |
4992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
160 ms |
4992 KB |
Output is correct |
2 |
Correct |
168 ms |
4992 KB |
Output is correct |
3 |
Correct |
160 ms |
4992 KB |
Output is correct |
4 |
Correct |
176 ms |
4992 KB |
Output is correct |
5 |
Correct |
156 ms |
4992 KB |
Output is correct |