#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll *ds, *de;
ll delivery(int N, int K, int L, int p[]) {
int s = 0, e = N - 1, k = K;
while(s <= e && p[s] == 0) ++s;
ds = new ll[N+1];
de = new ll[N+1];
if(s > e) return 0;
ll t = LLONG_MAX;
int si = s;
e = s;
de[N] = 0;
for(int i = N; i--;){
de[i] = L - p[i];
if(i + k < N) de[i] += de[i+k];
}
t = 2ll * de[si];
for(; s < N; s++){
ds[s] = p[s];
if(s-k >= si) ds[s] += ds[s-k];
for(e = s; e < N; e++) t = min(t, 2ll * (ds[s] + de[e+1]) + ll(e-s+k-1)/k * L);
}
for(e = si + 1; e < N; e++){
t = min(t, 2ll * de[e] + ll(e-si+k-2)/k * L);
}
//for(int i = 0; i <= N; i++) cout << ds[i] << ' '; cout << endl;
//for(int i = 0; i <= N; i++) cout << de[i] << ' '; cout << endl;
return t;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
8 ms |
376 KB |
Output is correct |
7 |
Correct |
8 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 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 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
8 ms |
376 KB |
Output is correct |
7 |
Correct |
8 ms |
376 KB |
Output is correct |
8 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
8 ms |
376 KB |
Output is correct |
7 |
Correct |
8 ms |
376 KB |
Output is correct |
8 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
8 ms |
376 KB |
Output is correct |
3 |
Correct |
8 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
8 ms |
376 KB |
Output is correct |
7 |
Correct |
8 ms |
376 KB |
Output is correct |
8 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |