Submission #79386

#TimeUsernameProblemLanguageResultExecution timeMemory
79386PlurmBoxes with souvenirs (IOI15_boxes)C++11
0 / 100
2 ms504 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<int> v; for(int i = 0; i < N; i++){ v.emplace_back(min(p[i],L-p[i])); } sort(v.begin(),v.end()); deque<int> dq; vector<long long> dp; dp.resize(N); dp[0] = 2ll*v[0]; dq.push_back(0); long long mn = (long long)(N+K-1)/(long long)K*(long long)L; for(int i = 1; i < N; i++){ mn = min(mn,dp[i-1] + (long long)(N-i+K-1)/(long long)K*(long long)L); while(!dq.empty() && i - dq.front() >= K) dq.pop_front(); dp[i] = dp[dq.front()] + 2ll*(long long)v[i]; while(!dq.empty() && dp[i] < dp[dq.back()]) dq.pop_back(); dq.push_back(i); } mn = min(mn,dp[N-1]); return mn; }
#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...