# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
268573 | A02 | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 384 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 <vector>
#include <set>
#include <algorithm>
#include <utility>
#include <iostream>
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
vector<long long> left_positions;
vector<long long> right_positions;
long long no_round_trips = 0;
for (int i = 0; i < N; i++){
if (p[i] <= L/2){
left_positions.push_back(p[i]);
}
}
for (int i = N - 1; i >= 0; i--){
if (p[i] > L/2){
right_positions.push_back(L - p[i]);
}
}
int current_boxes = 0;
while (left_positions.size() > 0){
no_round_trips += left_positions[left_positions.size() - 1] * 2;
current_boxes = K;
for (;left_positions.size() && current_boxes > 0; current_boxes--){
left_positions.pop_back();
}
}
while (right_positions.size() > 0){
no_round_trips += right_positions[right_positions.size() - 1] * 2;
current_boxes = K;
for (; right_positions.size() && current_boxes > 0; current_boxes--){
right_positions.pop_back();
}
}
long long one_round_trip = L;
for (int i = 0; i < N; i++){
if (p[i] <= L/2){
left_positions.push_back(p[i]);
}
}
for (int i = N - 1; i >= 0; i--){
if (p[i] > L/2){
right_positions.push_back(L - p[i]);
}
}
int current_l_index = 0;
current_boxes = 0;
while (current_l_index != left_positions.size()){
current_boxes = K;
while (current_boxes > 0 && current_l_index != left_positions.size()){
current_boxes--;
current_l_index++;
}
if (current_l_index != left_positions.size()){
one_round_trip += left_positions[current_l_index] * 2;
}
}
for (; right_positions.size() && current_boxes > 0; current_boxes--){
right_positions.pop_back();
}
while (right_positions.size() > 0){
one_round_trip += right_positions[right_positions.size() - 1] * 2;
current_boxes = K;
for (; right_positions.size() && current_boxes > 0; current_boxes--){
right_positions.pop_back();
}
}
return min(one_round_trip, no_round_trips);
return 0;
}
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... |