제출 #170607

#제출 시각아이디문제언어결과실행 시간메모리
170607mdn2002Stove (JOI18_stove)C++14
20 / 100
1103 ms200092 KiB
#include<bits/stdc++.h> using namespace std; const long long mod=998244353; long long n,k,a[5050],dp[5050][5050]; long long f(int x,int ma) { if(ma>k)return 1e18; if(x==n)return 0; if(dp[x][ma]!=-1)return dp[x][ma]; long long num=1e18; for(int i=x;i<n;i++) { num=min(num,f(i+1,ma+1)+a[i]-a[x]+1); } return dp[x][ma]=num; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); memset(dp,-1,sizeof dp); //freopen("lemonade.in","r",stdin); //freopen("lemonade.out","w",stdout); cin>>n>>k; for(int i=0;i<n;i++)cin>>a[i]; cout<<f(0,0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...