Submission #1084927

#TimeUsernameProblemLanguageResultExecution timeMemory
1084927guagua0407Boxes with souvenirs (IOI15_boxes)C++17
100 / 100
479 ms293968 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll,ll> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); const ll inf=1e18; long long delivery(int n, int k, int l, int p[]) { vector<ll> dp1(n+2),dp2(n+2); for(int i=1;i<k;i++){ dp1[i]=2*p[i-1]; } for(int i=k;i<=n;i++){ dp1[i]=dp1[i-k]+2*p[i-1]; } for(int i=n;i>n-k;i--){ dp2[i]=2*(l-p[i-1]); } for(int i=n-k;i>=1;i--){ dp2[i]=dp2[i+k]+2*(l-p[i-1]); } ll ans=inf; for(int i=0;i<=n;i++){ ans=min(ans,dp1[i]+dp2[i+1]); ans=min(ans,dp1[i]+l+dp2[min(n+1,i+k+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...