// Problem: https://oj.uz/problem/view/IOI15_boxes
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll delivery(int n, int k, int l, int pos[]) {
sort(pos, pos + n);
if (k == 1) { // subtask 1
ll ans = 0;
int mid = l >> 1;
for (int i = 0; i < n; i++) {
if (pos[i] <= mid) {
ans += 1ll * 2 * pos[i];
} else {
ans += 1ll * 2 * (l - pos[i]);
}
}
return ans;
} else if (k == n) { // subtask 2
ll ans = 0;
int mid = l >> 1;
if (pos[0] >= mid) {
ans += 1ll * 2 * (l - pos[0]);
} else if (pos[n - 1] <= mid) {
ans += 1ll * 2 * pos[n - 1];
} else {
ans = l;
}
return ans;
} else { // subtask 3-7
return 47;
}
}
# | 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... |