# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791743 | Josia | Boxes with souvenirs (IOI15_boxes) | C++17 | 1 ms | 212 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;
long long delivery(int N, int K, int L, int p[]) {
int res = 0;
map<int, int> poss;
for (int i = 0; i<N; i++) {
poss[p[i]]++;
}
int cnt = 0;
int startPos = (*poss.begin()).first;
int dist;
while (poss.size()) {
dist = (*poss.begin()).first;
poss[(*poss.begin()).first]--;
if (poss[(*poss.begin()).first] == 0) poss.erase(poss.begin());
cnt++;
if (cnt == K) {
if (dist > L/2 && startPos < L/2) res += L;
else res += min(dist*2, (L-dist)*2);
startPos = (*poss.begin()).first;
cnt = 0;
}
}
if (dist > L/2 && startPos < L/2) res += L;
else res += min(dist*2, (L-dist)*2);
startPos = (*poss.begin()).first;
cnt = 0;
// cerr << res << "\n";
return res;
}
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... |