#include <bits/stdc++.h>
//#include "grader.cpp"
#include "boxes.h"
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pii pair < int, pi >
#define vii vector < pi >
const int MAXN = 1e7 + 7;
const ll INF = 1e18 + 7;
ll pr[MAXN], sf[MAXN];
ll ans;
long long delivery(int N, int K, int L, int p[]) {
for (int i = 0; i < K; i++){
for (int j = 0; i + j * K < N; j++){
if (j)
pr[i + j * K] = pr[i + (j - 1) * K] + p[i + j * K] + min(p[i + j * K], L - p[i + j * K]);
else
pr[i + j * K] = p[i + j * K] + min(p[i + j * K], L - p[i + j * K]);
}
}
for (int i = N - 1; i >= 0; i--){
for (int j = 0; i - j * K >= 0; j++){
if (j)
sf[i - j * K] = sf[i - (j - 1) * K] + L - p[i - j * K] + min(p[i - j * K], L - p[i - j * K]);
else
sf[i - j * K] = L - p[i - j * K] + min(p[i - j * K], L - p[i - j * K]);
}
}
ans = sf[0];
for (int i = 0; i < N; i++)
ans = min(ans, pr[i] + sf[i + 1]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |