#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 |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
632 KB |
Output is correct |
2 |
Correct |
40 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
504 KB |
Output is correct |
2 |
Correct |
49 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
632 KB |
Output is correct |
2 |
Correct |
41 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
600 KB |
Output is correct |
2 |
Correct |
48 ms |
572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
676 KB |
Output is correct |
2 |
Correct |
48 ms |
508 KB |
Output is correct |