Submission #322423

#TimeUsernameProblemLanguageResultExecution timeMemory
322423tigichaBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms364 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; long long ans, dp1[10000001], dp2[10000001]; long long delivery(int n, int k, int l, int a[]){ for(long long i=0; i<n; i++) if(i>=k) dp1[i+1]=2*a[i]+a[i-k+1]; else dp1[i+1]=2*a[i]; for(long long i=n-1; i>=0; i--) if(i<n-k) dp2[i+1]=2*(l-a[i])+dp2[i+k+1]; else dp2[i+1]=2*(l-a[i]); ans=min(dp1[n], dp2[1]); for(long long i=1; i<=n-k+1; i++) ans=min(ans, dp1[i-1]+l+dp2[i+k]); for(long long i=1; i<n; i++) ans=min(ans, dp1[i]+dp2[i+1]); return ans; }
#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...