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;
int memo[10000];
int get(int arr[],int len,int cur){
if(memo[cur])
return memo[cur];
int result=1;
if(len-1==cur)
return 1;
for(int i=cur+1;i<len;i++){
if(arr[i]>=arr[cur])
result=max(result,1+get(arr,len,i));
}
return memo[cur]=result;
}
int main(void){ios_base::sync_with_stdio(false);cin.tie(0);
int n,k;
vector<pair<int,int> >skills;
int newarr[5000];
cin >> n >> k;
for(int i=0;i<n;i++){
int a;
cin >> a;
skills.push_back(make_pair(a,i));
}
sort(skills.begin(),skills.end());
for(int i=0;i<n;i++){
newarr[skills[i].second]=i/k;
}
int result=0;
for(int i=0;i<n;i++){
result=max(result,get(newarr,n,i));
}
cout << n-result;
}
# | 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... |