Submission #432964

#TimeUsernameProblemLanguageResultExecution timeMemory
432964vanicBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
926 ms238924 KiB
#include "boxes.h" #include <cmath> #include <algorithm> #include <vector> #include <iostream> using namespace std; typedef long long ll; const int maxn=1e7+5; ll dp1[maxn], dp2[maxn]; ll delivery(int n, int k, int l, int p[]) { sort(p, p+n); for(int i=0; i<n; i++){ dp1[i+1]=dp1[max(i+1-k, 0)]+p[i]*2; } for(int i=n-1; i>-1; i--){ dp2[i]=dp2[min(n, i+k)]+(l-p[i])*2; } ll mini=1e18; for(int i=0; i<=n; i++){ mini=min(mini, dp1[i]+dp2[i]); mini=min(mini, dp1[i]+dp2[min(n, i+k)]+l); } return mini; }
#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...