제출 #1155193

#제출 시각아이디문제언어결과실행 시간메모리
1155193aarb_.tomatexd선물상자 (IOI15_boxes)C++20
10 / 100
0 ms396 KiB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll delivery(int N, int K, int L, int positions[]) {
    ll total = 0;
    vector<int> right, left;

    for (int i = 0; i < N; i++) {
        int pos = positions[i];
        if (pos == 0) continue;
        if (pos <= L - pos)
            right.push_back(pos);
        else
            left.push_back(L - pos);
    }
    
    sort(right.begin(), right.end(), greater<int>());
    sort(left.begin(), left.end(), greater<int>());
    
    for (int i = 0; i < (int)right.size(); i += K)
        total += 2LL * right[i];
    
    for (int i = 0; i < (int)left.size(); i += K)
        total += 2LL * left[i];
    
    return total;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...