Submission #793451

#TimeUsernameProblemLanguageResultExecution timeMemory
793451MarkynoodleBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;


#define ll long long


ll delivery(int n, int k, int l, vector<int> pos){
    ll sol = 1e16;
    sort(pos.begin(), pos.end());
    for(int i = 0; i<=n; i++){

        ll tempsol = 0;
        int cnt = 0;
        int cycle = 0;
        while(cnt < i){


            if(cnt + 1 == i){
                tempsol += pos[cnt];
                tempsol += min(pos[cnt], l - pos[cnt]);
                break;
            }
            if(cycle == k){
                tempsol += pos[cnt];
                tempsol += min(pos[cnt], l - pos[cnt]);
                cycle = 0;
            }
            cnt++;
            cycle++;
        }
        //cout<<tempsol<<" ";
        cnt = n;
        cycle = 0;
        while(cnt >= i){
            if(cnt == i){
                tempsol += l - pos[cnt];
                tempsol += min(pos[cnt], l - pos[cnt]);
                break;
            }
            if(cycle == k){
                tempsol += l - pos[cnt];
                tempsol += min(pos[cnt], l - pos[cnt]);
                cycle = 0;
            }
            cnt--;
            cycle++;
        }
        sol = min(sol, tempsol);
        //cout<<tempsol<<"_";

    }

    return sol;
}

Compilation message (stderr)

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