# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1008398 | andro | Boxes with souvenirs (IOI15_boxes) | C++14 | 0 ms | 436 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 <bits/stdc++.h>
#include "boxes.h"
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
long long ans = 0;
vector<int> b1, b2;
for(int i = 0; i < N; i++) {
if(p[i] <= L - p[i]) {
b1.push_back(p[i]);
}
else {
b2.push_back(p[i]);
}
}
int r = K;
for(int i = 0; i < b1.size(); i++) {
r -= 1;
if(! r) {
ans += b1[i] * 2;
r = K;
}
else {
continue;
}
}
int idx = b2.size() - 1;
if(r != K) {
while(r > 0) {
idx -= 1;
r -= 1;
}
ans += (L - b2[idx + 1]) * 2;
}
r = K;
for(int i = 0; i <= idx; i++) {
r -= 1;
if(! r) {
ans += (L - b2[i]) * 2;
r = K;
}
else {
continue;
}
}
if(r != K) {
if(r > 0) {
ans += (L - b2[idx]) * 2;
}
}
return ans;
}
/*
int main() {
int X[3] = {1, 2, 5};
cout << delivery(3, 2, 8, X);
}
*/
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... |