제출 #94025

#제출 시각아이디문제언어결과실행 시간메모리
94025brcode오렌지 출하 (JOI16_ho_t1)C++14
0 / 100
3 ms508 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const long long MAXN = 100010; long long arr[MAXN]; long long dp[MAXN]; long long n,m,k; long long rec(long long x,long long y,long long z){ if(x>=n){ return 0; } if(dp[x]){ return dp[x]; } long long maxo = arr[x]; long long mino = arr[x]; long long ans = 1000000000; for(long long i=x;i<min(n,x+y);i++){ //long long incto = i+x; maxo = max(maxo,arr[i]); mino = min(mino,arr[i]); long long diff = maxo-mino; long long cost = z+(i-x+1)*diff; long long final = cost + rec(i+1,y,z); ans = min(final,ans); } return dp[x] = ans; } int main() { cin>>n>>m>>k; for(long long i=0;i<n;i++){ cin>>arr[i]; } cout<<rec(0,m,k)<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...