# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
268573 | A02 | 선물상자 (IOI15_boxes) | C++14 | 1 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |