Submission #792149

#TimeUsernameProblemLanguageResultExecution timeMemory
792149JosiaBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
434 ms196780 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define int int64_t long long delivery(signed N, signed K, signed L, signed p[]) { vector<int> costUntilCW(N); vector<int> costUntilCCW(N); for (int i = 0; i<N; i++) { costUntilCW[i] = (i-K>=0?costUntilCW[i-K]:0)+p[i]; // cerr << costUntilCW[i] << " "; } // cerr << "\n"; for (int i = N-1; i>=0; i--) { costUntilCCW[i] = (i+K<N?costUntilCCW[i+K]:0)+L-p[i]; // cerr << costUntilCCW[i] << " "; } // cerr << "\n"; int res = min(costUntilCW[N-1]*2, costUntilCCW[0]*2); res = min(res, costUntilCW[max(0, N-1-K)]*2 + L); res = min(res, costUntilCCW[min(N-1, K)]*2 + L); if (K >= N) res = min(res, (int)L); for (int i = 0; i<N-1; i++) { res = min(res, costUntilCW[i]*2 + costUntilCCW[i+1]*2); if (i+K+1 < N) res = min(res, costUntilCW[i]*2 + costUntilCCW[i+K+1]*2 + L); } return res; }
#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...