Submission #779795

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7797952023-07-11 20:38:24zsomborBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
498 ms293708 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include "boxes.h"
using namespace std;
using ll = long long;
vector <ll> l(1e7, 0);
vector <ll> r(1e7, 0);
ll delivery(int N, int K, int L, int p[]) {
for (int i = 0; i < N; i++) l[i] = i < K ? 2 * p[i] : l[i - K] + 2 * p[i];
for (int i = N - 1; i >= 0; i--) r[i] = i >= N - K ? 2 * (L - p[i]) : r[i + K] + 2 * (L - p[i]);
ll ans = 1e17;
ans = min(ans, r[0]);
ans = min(ans, l[N - 1]);
for (int i = 0; i < N - 1; i++) ans = min(ans, l[i] + r[i + 1]);
ans = min(ans, r[K] + L);
ans = min(ans, l[N - K - 1] + L);
for (int i = 0; i < N - K - 1; i++) ans = min(ans, l[i] + r[i + K + 1] + L);
return ans;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...