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>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
ll n,k,mx;
ll arr[5005],dp[5005];
pair<ll,ll>arr1[5005];
void solve(){
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>arr[i];
arr1[i]={arr[i],i};
}
sort(arr1,arr1+n);
for(int i=0;i<n;i++) arr[arr1[i].second]=i/k;
for(int i=0;i<n;i++){
dp[i]=1;
for(int j=0;j<i;j++) if(arr[i]>=arr[j]) dp[i]=max(dp[i],dp[j]+1);
mx=max(mx,dp[i]);
}
co n-mx;
}
int main()
{
suiii
int _=1;
// cin>>_;
while(_--) solve();
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... |