Submission #1015361

#TimeUsernameProblemLanguageResultExecution timeMemory
1015361amine_aroua선물상자 (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#define intt long long
multiset<int> pos;
int l;
intt minDist(int i , int j)
{
    return min(abs(i - j) , l - abs(i - j));
}
int comb(int it1 , int it2 , int p)
{
    if(minDist(p , it1) > minDist(p , it2))
        return it2;
    return it1;
}
long long delivery(int N, int K, int L, vector<int> p)
{
    l = L;
    for(int i = 0 ; i < N ; i++)
        pos.insert(p[i]);
    int beg = 0;
    intt ans = 0;
    while(!pos.empty())
    {
        int cnt = K;
        ans+= minDist(beg , 0);
        beg = 0;
        while(!pos.empty() && cnt--)
        {
            int best = *pos.begin();
            best = comb(best , *pos.rbegin() , beg);
            if(pos.lower_bound(beg) != pos.end())
            {
                best = comb(best , *pos.lower_bound(beg) , beg);
            }
            if(pos.lower_bound(beg) != pos.begin())
            {
                best = comb(best , *prev(pos.lower_bound(beg)) , beg);
            }
            ans+= minDist(best , beg);
            pos.erase(pos.find(best));
            beg = best;
        }
    }

    ans+= minDist(0 , beg);
    return ans;
}

/*
int main() {
    int N , K , L;
    cin>>N>>K>>L;
    vector<int> p(N);
    for(auto &x : p)
        cin>>x;
    cout<<delivery(N , K , L, p)<<endl;
}
*/

Compilation message (stderr)

/usr/bin/ld: /tmp/ccZdHUB2.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status