# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780062 | vjudge1 | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 340 KiB |
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 "boxes.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<long long, long long>
#define st first
#define nd second
#define sp " "
#define endl "\n"
#define ll long long
long long delivery(int N, int K, int L, int p[]) {
int n = N, k = K, l = L;
sort(p, p + n);
ll curr = 0;
for (int i = 0; i < n; i += k){
int to = min(n - 1, i + k - 1);
if (p[to] <= L / 2){
curr += 2 * p[to];
}
else if (p[i] >= L / 2){
curr += 2 * (L - p[i]);
}
else curr += L;
}
ll ans = curr;
curr = 0;
reverse(p, p + n);
for (int i = 0; i < n; i += k){
int to = min(n - 1, i + k - 1);
if (p[i] <= L / 2){
curr += 2 * p[i];
}
else if (p[to] >= L / 2){
curr += 2 * (L - p[to]);
}
else curr += L;
}
return min(ans, curr);
}
Compilation message (stderr)
# | 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... |