This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "boxes.h"
#define forint(i, N) for (int i = 0; i < (N); i++)
using namespace std;
typedef long long ll;
ll delivery(int n, int k, int l, int p[]) {
vector<int> dist(n);
for (int i = 0; i < n; i++) {
dist[i] = min(p[i], l - p[i]);
}
/*for (auto& i : dist) {
cerr << i << " ";
}
cerr << endl;
*/
ll ret = 0;
int pos = 0;
int a = 0;
while (pos < n) {
if (a != 0) {
ret += (ll)p[pos] - p[pos - 1];
}
else {
ret += (ll)dist[pos];
}
a++;
//cerr << "ja - " << a << endl;
if (a == k || (pos < n - 1 && 2 * (p[pos + 1] - p[pos]) > 2 * dist[pos + 1]) || pos == n - 1) {
ret += (ll)dist[pos];
a = 0;
}
//cerr << pos << " - " << ret << endl;
pos++;
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |