이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
int N,K,L;
int clst(int x){
    if(x>L/2) x=L-x;
    return (x)*2;
}
long long delivery(signed _n, signed _k, signed _l, signed p[]) {
    N=_n;
    K=_k;
    L=_l;
    vector<int> a(N);
    vector<int> marked(N);
    for (int i = 0; i < N; i++) a[i]=p[i];
    sort(a.begin(),a.end());
    int sumFULL=L;
    int sumNOTFULL=0;
    int lmt=N;
    vector<pair<int,int>> res;
    vector<int> res2;
    vector<int> res3;
    for (int i = 0; i < N; i++) { res.push_back({abs(L-2*a[i]),i}); }
    sort(all(res));
    for (int i = 0; i < sz(res); i++)
    {
        if(i<K) res3.push_back(res[i].second);
        else {
            res3.push_back(res[i].second);
            res2.push_back(res[i].second);
        }
    }
    sort(all(res2));
    sort(all(res3));
    lmt=sz(res2);
    for (int i = 0; i < sz(res2); i++) { if(a[res2[i]]>L/2) { lmt=i; break; } }
    for (int i = lmt-1; i >= 0; i-=K) sumFULL+=a[res2[i]]*2;
    for (int i = lmt; i < sz(res2); i+=K) sumFULL+=(L-a[res2[i]])*2;
    lmt=sz(res3);
    for (int i = 0; i < sz(res3); i++) { if(a[res3[i]]>L/2) { lmt=i; break; } }
    for (int i = lmt-1; i >= 0; i-=K) sumNOTFULL+=a[res3[i]]*2;
    for (int i = lmt; i < sz(res3); i+=K) sumNOTFULL+=(L-a[res3[i]])*2;
    return min(sumFULL,sumNOTFULL);
}
| # | 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... |