Submission #544121

#TimeUsernameProblemLanguageResultExecution timeMemory
544121krit3379Boxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms308 KiB
#include<bits/stdc++.h> using namespace std; #define N 10000005 long long dp1[N],dp2[N],ans=1e18; long long delivery(int n,int k,int l,int pos[N]){ int i; sort(pos,pos+n); for(i=0;i<n;i++){ if(i>=k)dp1[i]=dp1[i-k]+2*pos[i]; else dp1[i]=2*pos[i]; } for(i=n-1;i>=0;i--){ if(i+k<n)dp2[i]=dp2[i+k]+2*(l-pos[i]); else dp2[i]=2*(l-pos[i]); } for(i=0;i+1<n;i++)ans=min(ans,dp1[i]+dp2[i+1]); for(i=0;i+k+1<n;i++)ans=min(ans,dp1[i]+dp2[i+k+1]+l); 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...