# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
785275 | acatmeowmeow | Boxes with souvenirs (IOI15_boxes) | C++11 | 498 ms | 293644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e7;
long long prefix[N + 5], suffix[N + 5];
long long delivery(int N, int K, int L, int p[]) {
for (int i = 0; i < N; i++) prefix[i] = (i - K >= 0 ? prefix[i - K] : 0ll) + (long long)p[i] + (long long)min(p[i], L - p[i]);
for (int i = N - 1; i >= 0; i--) suffix[i] = (i + K < N ? suffix[i + K] : 0ll) + (long long)L - p[i] + (long long)min(p[i], L - p[i]);
long long ans = min(prefix[N - 1], suffix[0]);
for (int i = 0; i + 1 < N; i++) ans = min(ans, prefix[i] + suffix[i + 1]);
return ans;
}
/*int main() {
int n, k, l;
cin >> n >> k >> l;
int p[n];
for (int i = 0; i < n; i++) cin >> p[i];
long long ans = delivery(n, k, l, p);
cout << ans << '\n';
return 0;
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |