Submission #123885

#TimeUsernameProblemLanguageResultExecution timeMemory
123885khulegubBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
66 ms78736 KiB
#include "boxes.h" #include <algorithm> #include <cstring> #define pb push_back using namespace std; typedef long long i64; i64 lsum[10000010], rsum[10000010]; i64 zeze[10000010]; int n; int l; int k; i64 delivery(int N, int K, int L, int p[]) { n = N; l = L; k = K; for (int i = 0; i < n; i++){ zeze[i % k] += 2 * p[i]; lsum[i] = zeze[i % k]; } memset(zeze, 0, sizeof zeze); for (int i = n - 1; i >= 0; i--){ zeze[i % k] += 2 * (l - p[i]); rsum[i] = zeze[i % k]; } i64 ans = 1e9; for (int i = 0; i <= n; i++){ if (i == 0) ans = min(ans, rsum[i]); else ans = min(ans, lsum[i - 1] + rsum[i]); } for (int i = 0; i <= n - k; i++){ if (i == 0) ans = min(ans, rsum[i + k] + l); else ans = min(ans, lsum[i - 1] + rsum[i + k] + 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...