#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> V, v;
long long delivery(int N, int K, int L, int p[]) {
int l=0, i;
long long ans=0;
V.resize(N);
for (i=0; i<N; i++) {if (p[i]>L/2) {l=i; break;}}
for (i=K-1; i<=l; i+=K) {ans+=(long long)(p[i]*2);}
for (i=max(i-K+1, 0); i<=l; i++) {V[i]=1;}
for (i=N-K; i>l; i-=K) {ans+=(long long)((L-p[i])*2);}
for (i=min(i+K-1, N-1); i>l; i--) {V[i]=1;}
v.push_back(0);
for (i=0; i<N; i++) {if (V[i]) v.push_back(p[i]);}
v.push_back(L);
int mx=0;
for (i=max(0, (int)v.size()-K-2); i<min(K+1, (int)v.size()-1); i++) {mx=max(mx, v[i+1]-v[i]);}
//for (int j:v) printf("%d ", j); puts("");
ans+=(long long)(2*L-2*mx);
//printf("%lld\n", ans);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |