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;
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,k;
cin >> n >> k;
int arr[n];
pair<int,int> srt[n];
for(int i=0; i<n; i++){
cin >> srt[i].first;
srt[i].second=i;
}
sort(srt,srt+n);
for(int i=0; i<n; i+=k){
for(int j=0; j<k; j++){
arr[srt[i+j].second]=i/k;
}
}
int dp[n],ans=0;
for(int i=0; i<n; i++){
dp[i]=1;
for(int j=0; j<i; j++) if(arr[j]<=arr[i]) dp[i]=max(dp[i],dp[j]+1);
ans=max(ans,dp[i]);
}
cout << n-ans;
return 0;
}
# | 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... |