#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
int N, M, K;
int A[10101010];
LL L[10101010], R[10101010], ans=(1ll<<61);
LL delivery(int n, int m, int k, int a[]){
N = n, M = m, K = k;
for (int i=1, j=0; i<=N; i++, j++) {
if (!a[j]) i--, N--;
A[i] = a[j];
}
for (int i=1; i<=N; i++){
if (i%M == 1) L[i] = L[i-1]+min(A[i]*2, K);
else L[i] = L[i-1]-min(A[(i-1)/M*M+1]*2, K)+min(A[i]*2, K);
}
for (int i=1; i<=N/2; i++) swap(A[i], A[N-i+1]);
for (int i=1; i<=N; i++){
if (i%M == 1) R[i] = R[i-1]+min((K-A[i])*2, K);
else R[i] = R[i-1]-min((K-A[(i-1)/M*M+1])*2, K)+min((K-A[i])*2, K);
}
for (int i=0; i<=N; i++) ans = min(ans, L[i]+R[N-i]);
return ans;
}
# |
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 |
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 |
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 |
- |