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 nx=5e3+5;
int n, k, v[nx], t, res=INT_MAX, dp[nx];
map<int, int> mp;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>k;
for (int i=1; i<=n; i++) cin>>v[i], mp[v[i]]=0;
for (auto &[x, y]:mp) y=(t/k)+1, t++;
for (int i=1; i<=n; i++) v[i]=mp[v[i]];
for (int i=1; i<=n; i++)
{
dp[i]=1;
for (int j=1; j<i; j++) if (v[j]<=v[i]) dp[i]=max(dp[i], dp[j]+1);
res=min(res, n-dp[i]);
}
cout<<res;
}
# | 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... |