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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define maxn 5005
int n,k;
vector<pair<int,int>> v;
int a[maxn], dp[maxn];
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++) {
int x; cin >> x;
v.push_back({x,i});
}
sort(v.begin(),v.end());
for (int i = 0; i < n; i++) {
a[v[i].second] = i / k;
}
int lis = 0;
for (int i = 0; i < n; i++) {
dp[i] = 1;
for (int j = 0; j < i; j++) {
if (a[j] <= a[i]) {
dp[i] = max(dp[i],1+dp[j]);
}
}
lis = max(lis,dp[i]);
}
cout << n - lis << endl;
}
# | 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... |