# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1051194 | ArthuroWich | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 348 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>
#define int long long int
using namespace std;
int delivery(int32_t n, int32_t k, int32_t l, int32_t P[]) {
int ans = 0;
deque<int> p;
for (int i = 0; i < n; i++) {
p.push_back(P[i]);
}
sort(p.begin(), p.end());
while(p.front() == 0) {
p.pop_front();
}
while(!p.empty()) {
int a = 0, b = 0, coa = 0, cob = 0;
for (int i = 0; i < p.size(); i++) {
if (p[i] <= l-p[i] || p[i]+l-p[i] <= 2*a+2*(l-p[i])) {
a = p[i];
coa++;
}
if (coa == k) {
break;
}
}
ans += a+min(a, l-a);
while(coa--) {
p.pop_front();
}
if (p.empty()) {
break;
}
for (int i = p.size()-1; i >= 0; i--) {
if (p[i] >= l-p[i] || p[i]-l+p[i] <= 2*p[i]+2*(l-b)) {
b = p[i];
cob++;
}
if (cob == k) {
break;
}
}
while(cob--) {
p.pop_back();
}
ans += l-b+min(b, l-b);
}
return ans;
}
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... |