# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40625 | Hassoony | Studentsko (COCI14_studentsko) | C++14 | 1 ms | 416 KiB |
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>
#include<unordered_map>
using namespace std;
typedef unsigned long long ll;
typedef double D;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=5009;
int n,k,a[MX],dp[MX][MX];
int DP(int x,int y){
if(x==n)return 0;
int &ret=dp[x][y];if(ret!=-1)return ret;
ret=DP(x+1,y);
if(a[x]>=y)ret=max(ret,DP(x+1,a[x])+1);
return ret;
}
map<int,int>hashy;
int b[MX];
int main(){
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++)scanf("%d",&a[i]),b[i]=a[i];
sort(b,b+n);
for(int i=0;i<n;i++){
hashy[b[i]]=i/k;
}
for(int i=0;i<n;i++)a[i]=hashy[a[i]];
memset(dp,-1,sizeof(dp));
printf("%d\n",n-DP(0,0));
}
Compilation message (stderr)
# | 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... |