Submission #94023

#TimeUsernameProblemLanguageResultExecution timeMemory
94023brcode오렌지 출하 (JOI16_ho_t1)C++14
0 / 100
3 ms504 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MAXN = 100010; int arr[MAXN]; int dp[MAXN]; int n,m,k; int rec(int x,int y,int z){ if(x>=n){ return 0; } if(dp[x]<1000000000){ return dp[x]; } int maxo = arr[x]; int mino = arr[x]; int ans = 1000000000; for(int i=x;i<min(n,x+y);i++){ //int incto = i+x; maxo = max(maxo,arr[i]); mino = min(mino,arr[i]); int diff = maxo-mino; int cost = z+(i-x+1)*diff; int final = cost + rec(i+1,y,z); ans = min(final,ans); } return dp[x] = ans; } int main() { cin>>n>>m>>k; for(int i=0;i<n;i++){ cin>>arr[i]; dp[i] = 1000000000; } cout<<rec(0,m,k)<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...