Submission #209366

#TimeUsernameProblemLanguageResultExecution timeMemory
209366autumn_eelBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
128 ms81400 KiB
#include "boxes.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; const ll INF=0x3f3f3f3f3f3f3f3f; ll dp[2000][2000]; long long delivery(int N, int K, int L, int p[]) { memset(dp,0x3f,sizeof(dp)); dp[0][0]=0; rep(i,N)rep(j,K){ if(dp[i][j]==INF)continue; if(j==0){ dp[i+1][0]=min(dp[i+1][0],dp[i][j]+min(p[i],L-p[i])*2); if(1<K)dp[i+1][1]=min(dp[i+1][1],dp[i][j]+min(p[i],L-p[i])); } else{ dp[i+1][0]=min(dp[i+1][0],dp[i][j]+min(p[i],L-p[i])+(p[i]-p[i-1])); if(j+1<K)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+(p[i]-p[i-1])); } } return dp[N][0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...