제출 #1123301

#제출 시각아이디문제언어결과실행 시간메모리
1123301ezzzayRabbit Carrot (LMIO19_triusis)C++20
0 / 100
1102 ms196500 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=5005; int dp[N][N]; int a[N]; signed main(){ for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ dp[i][j]=1e9; } } int n,k; cin>>n>>k; for(int i=1;i<=n;i++)cin>>a[i]; dp[0][0]=0; int ans=n; for(int i=1;i<=n;i++){ for(int j=0;j<i;j++){ for(int hi=0;hi<=1000;hi++){ for(int hj=0;hj<=1000;hj++){ if(hi-hj>k)continue; if(hi!=a[i]){ dp[i][hi]=min(dp[i][hi],dp[j][hj]+1); ans=min(ans,dp[i][hi]); } } } } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...