#include "boxes.h"
#include <iostream>
#include <algorithm>
using namespace std;
#define long long long
const int N = 2e7 + 2;
long fsuff[N], fpref[N];
long delivery(int n, int k, int L, int p[]) {
int head = 0;
while (head < n && p[head] == 0) ++head;
long res = (long) (n - head + k - 1) / k * L;
for (int i = n - 1; i >= head; --i)
fsuff[i] = fsuff[i + k] + (L - p[i]) * 2;
// for (int i = head; i < n; ++i)
// cerr << fsuff[i] << ' ';
// cerr << '\n';
int full = 0;
while (full * k <= n - head && fsuff[head + (full + 1) * k] + L < fsuff[head + full * k]) ++full;
res = min(res, fsuff[head + full * k] + full * k);
for (int i = head; i < n; ++i)
{
fpref[i] = (i < k ? 0 : fpref[i - k]) + p[i] * 2;
#define eval(x) (fsuff[i + 1 + (x) * k] + (long) (x) * L)
while (full > 0 && eval(full - 1) < eval(full)) --full;
res = min(res, fpref[i] + eval(full));
#undef eval
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
296 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
420 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |