Submission #102245

# Submission time Handle Problem Language Result Execution time Memory
102245 2019-03-23T20:27:45 Z Leonardo_Paes Boxes with souvenirs (IOI15_boxes) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 3e7 + 10;

int n, k, l, vet[MAXN];

typedef long long ll;

ll pre[MAXN], suf[MAXN];

ll delivery(int N, int K, int L, int positions[]){

    ll sum;

    for(int i=0; i<n; i++){
        pre[i] = 2ll*positions[i];
        if(i >= k)pre[i] += pre[i-k];
    }

    for(int i=n-1; i>=0; i--){
        suf[i] = 2ll*(L-positions[i]);
        if(i+k < n)suf[i] += suf[i+k];
    }

    sum = min(suf[0], pre[N-1]);

    if(N==K)sum=min(sum, (ll)L);

    for(int i=0; i<N-1; i++){
        sum = min(sum, pre[i] + suf[i+1]);
        if(i+K+1<n)sum = min(sum, pre[i] + L + suf[i+1+K]);
        else sum = min(sum, pre[i] + L);
    }

    return sum;
}

int main(){
    cin >> n >> k >> l;
    for(int i=0; i<n; i++){
        cin >> vet[i];
    }
    cout <<  delivery(n, k, l, vet) << endl;
}

Compilation message

/tmp/ccoaoInt.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/ccWeppd1.o:boxes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status