제출 #1123304

#제출 시각아이디문제언어결과실행 시간메모리
1123304ezzzayRabbit Carrot (LMIO19_triusis)C++20
14 / 100
1102 ms196508 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 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[i-1][hj]+1); if(i==n)ans=min(ans,dp[i][hi]); } else{ dp[i][hi]=min(dp[i][hi],dp[i-1][hj]); if(i==n)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...