#include "boxes.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdio>
#include <utility>
#include <queue>
#include <math.h>
#include <set>
#include <bitset>
#include <cmath>
#include <bitset>
#include <stack>
#include <cstring>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 10000010;
ll pre1[MAXN];
ll pre2[MAXN];
ll delivery(int n, int k, int l, int p[]) {
for(int i = 0; i < n; i++) {
if(i < k) pre1[i] = (ll)2 * (ll)p[i];
else pre1[i] = (ll)2 * (ll)p[i] + pre1[i - k];
}
for(int i = n - 1; i >= 0; i--) {
if(i > n - 1 - k) pre2[i] = (ll)2 * ((ll)l - (ll)p[i]);
else pre2[i] = (ll)2 * ((ll)l - (ll)p[i]) + pre2[i - k];
}
ll ans = min(pre1[n - 1], pre2[0]);
for(int i = 0; i < n - 1; i++)
ans = min(ans, pre1[i] + pre2[i + 1]);
if(n == k) return min(ans, (ll)l);
ans = min(ans, min(pre1[n - k - 1] + (ll)l, pre2[k] + (ll)l));
for(int i = 0; i < n - k - 1; i++)
ans = min(ans, pre1[i] + (ll)l + pre2[i + k + 1]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |