#include <iostream>
#include <cstring>
using namespace std;
int n;
int a[201], cache[201];
int lis(int b){
int&ret=cache[b];
if(ret!=-1) return ret;
ret=1;
for(int i=b+1; i<n; ++i){
if(a[b]<a[i])
ret=max(ret, lis(i)+1);
}
return ret;
}
int main(){
scanf("%d", &n);
memset(cache, -1, sizeof(cache));
for(int i=0; i<n; ++i)
scanf("%d",&a[i]);
int ans=-1;
for(int i=0; i<n; ++i)
ans=max(ans,lis(i));
printf("%d\n", n-ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1676 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1676 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
1676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
1672 KB |
futex (syscall #202) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
1672 KB |
futex (syscall #202) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |