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 <cstdio>
#include <algorithm>
using namespace std;
int n, k, a[5010], b[5010], dt[5010], ans;
int main(){
scanf("%d%d", &n, &k);
for(int i = 0; i < n; i++){
scanf("%d", a + i);
b[i] = a[i];
}
sort(b, b + n);
for(int i = 0; i < n; i++){
a[i] = (lower_bound(b, b + n, a[i]) - b) / k;
}
dt[0] = 1;
for(int i = 1; i < n; i++){
dt[i] = 1;
for(int j = 0; j < i; j++){
if(a[j] <= a[i]) dt[i] = max(dt[i], dt[j] + 1);
}
}
for(int i = 1; i < n; i++) ans = max(ans, dt[i]);
printf("%d", n - ans);
}
# | 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... |
# | 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... |