Submission #786585

#TimeUsernameProblemLanguageResultExecution timeMemory
786585I_Love_EliskaM_Boxes with souvenirs (IOI15_boxes)C++14
100 / 100
676 ms345488 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define forn(i,n) for(int i=0;i<n;++i) #define pb push_back #define all(x) x.begin(),x.end() using ll = long long; const ll inf = 1e18; ll delivery(int n, int k, int l, int p[]) { #define int ll vector<int> a; forn(i,n) a.pb(p[i]); vector<int> dp1,dp2; dp1.pb(0); forn(i,n) { if (i<k) dp1.pb(min(2*a[i],1ll*l)); else dp1.pb(min(2*a[i],1ll*l)+dp1[i-k+1]); } forn(i,n) a[i]=l-a[i]; reverse(all(a)); dp2.pb(0); forn(i,n) { if (i<k) dp2.pb(min(2*a[i],1ll*l)); else dp2.pb(min(2*a[i],1ll*l)+dp2[i-k+1]); } reverse(all(dp2)); ll ans=inf; forn(i,n+1) ans=min(ans,dp1[i]+dp2[i]); return ans; #undef int }
#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...