이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
short int n,k;
short int a[MX];
short int dp[MX][MX];
short int DP(int x,int y){
if(x==n)return 0;
short int &ret=dp[x][y];if(ret!=-1)return ret;
ret=DP(x+1,y);
short int x1=1;
if(a[x]>=y)x1+=DP(x+1,a[x]),ret=max(ret,x1);
return ret;
}
map<int,int>hashy;
short int b[MX];
int main(){
cin>>n>>k;
for(int i=0;i<n;i++)cin>>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]];
for(int i=0;i<MX;i++){
for(int j=0;j<MX;j++){
dp[i][j]=-1;
}
}
cout<<n-DP(0,0)<<endl;
}
# | 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... |