이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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.empty()) {
int a = 0, b = p.back(), co = k;
a = p[min((int)k, (int)p.size())-1];
b = l-p[max(0LL, (int)p.size()-k)];
a += min(a, l-a);
b += min(b, l-b);
if (a < b) {
ans += a;
while(co-- && !p.empty()) {
p.pop_front();
}
} else {
ans += b;
while(co-- && !p.empty()) {
p.pop_back();
}
}
}
return ans;
}
# | 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... |