Submission #692060

#TimeUsernameProblemLanguageResultExecution timeMemory
692060zeroesandonesBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
540 ms293744 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long; using pi = pair<ll, ll>; using vi = vector<ll>; #define pb emplace_back ll delivery(int N, int K, int L, int p[]) { ll pref[N + 2] = {}; ll suff[N + 2] = {}; for(int i = 1; i <= N; ++i) { pref[i] = p[i - 1] * 2; if(i > K) pref[i] += pref[i - K]; } for(int i = N; i >= 1; --i) { suff[i] = (L - p[i - 1]) * 2; if(i <= N - K) suff[i] += suff[i + K]; } ll ans = LLONG_MAX; for(int i = 0; i <= N; ++i) { ans = min(ans, pref[i] + suff[i + 1]); } for(int i = K; i <= N; ++i) { ans = min(ans, pref[i - K] + suff[i + 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...