Submission #963662

#TimeUsernameProblemLanguageResultExecution timeMemory
963662hirayuu_ojBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms348 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define all(x) x.begin(),x.end() using ll=long long; const ll INF=1LL<<60; long long delivery(int N, int K, int L, int p[]) { vector<ll> dp(N+1,0); rep(i,N){ dp[i+1]=p[i]+dp[max(0,i+1-K)]+min(p[i],L-p[i]); } vector<ll> dp2(N+1,0); rep(i,N){ p[i]=(L-p[i])%L; } vector<int> ps(N); rep(i,N){ ps[i]=p[i]; } sort(all(ps)); rep(i,N){ dp2[i+1]=ps[i]+dp2[max(0,i+1-K)]+min(ps[i],L-ps[i]); } ll ans=INF; rep(i,N+1){ ans=min(ans,dp[i]+dp2[N-i]); } 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...