Submission #321213

#TimeUsernameProblemLanguageResultExecution timeMemory
321213wildturtleBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
572 ms293144 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; long long ans,dp[10000007],dp1[10000007]; long long delivery(int N, int K, int L, int p[]) { for(long long i=0;i<N;i++) { if(i<K) dp[i+1]=2*p[i]; else dp[i+1]=2*p[i]+dp[i-K+1]; // cout<<dp[i+1]<<" "; } //cout<<endl; for(long long i=N-1;i>=0;i--) { if(i>=N-K) dp1[i+1]=2*(L-p[i]); else dp1[i+1]=2*(L-p[i])+dp1[i+K+1]; // cout<<dp1[i+1]<<" "; } //cout<<endl; //cout<<ans<<endl; ans=min(dp[N],dp1[1]); for(long long i=1;i<=N-K+1;i++) { // cout<<dp[i-1]+L+dp1[i+K]<<endl; ans=min(ans,dp[i-1]+L+dp1[i+K]); } for(long long i=1;i<N;i++) ans=min(ans,dp[i]+dp1[i+1]); return ans; }/* int main() { int A[]={1,2,5}; cout<<delivery(3,2,8,A); }*/
#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...