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 <bits/stdc++.h>
using namespace std;
const int N = 5002;
int a[N], b[N], d[N];
map<int,int> m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, k; cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i]; b[i] = a[i];
}
sort(b + 1, b + n + 1);
for (int i = 1; i <= n; i++) {
m[b[i]] = (i - 1) / k;
}
for (int i = 1; i <= n; i++) {
a[i] = m[a[i]];
}
int mx = 0;
for (int i = 1; i <= n; i++) {
for (int j = i; j; j--) {
if (a[i] >= a[j]) {
d[i] = max(d[i], d[j] + 1);
}
}
mx = max(mx, d[i]);
}
cout << n - mx << endl;
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... |
# | 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... |