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;
#define ll long long
const ll inf=1e9;
const int maxn=100;
const ll mod=1e9+7;
void solve(){
int a,k;
cin>>a>>k;
vector <pair<int,int>> b(a);
for(int i=0;i<a;i++){
cin>>b[i].first;
b[i].second=i;
}
sort(b.begin(),b.end());
vector <int> h(a);
for(int i=0;i<a;i++){
h[b[i].second]=i/k;
}
vector <int> dp(a+5);
int ans=0;
for(int i=0;i<a;i++){
dp[i]=1;
for(int t=0;t<i;t++){
if(h[i]>=h[t]){
dp[i]=max(dp[i],dp[t]+1);
}
}
ans=max(ans,dp[i]);
}
cout<<a-ans;
}
int main(){
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int t=1;
//cin>>t;
while(t--){
solve();
cout<<'\n';
}
}
# | 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... |