Submission #284523

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2845232020-08-27 14:36:46IOrtroiiiBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
int64_t delivery(int N, int K, int L, int p[]) {
vector<int64_t> pref(N);
vector<int64_t> suff(N);
for (int i = 0; i < N; ++i) {
pref[i] = 2 * p[i];
if (i >= K) pref[i] += pref[i - K];
}
for (int i = N - 1; i >= 0; --i) {
suff[i] = 2 * (L - p[i]);
if (i + K < N) suff[i] += suff[i + K];
}
int64_t ans = min(pref[N - 1], suff[0]);
for (int i = 0; i + 1 < N; ++i) ans = min(ans, pref[i] + suff[i + 1]);
for (int i = 0; i + 1 + K < N; ++i) ans = min(ans, pref[i] + suff[i + 1 + K] + L);
return ans;
}
int main() {
int p[] = {1, 2, 5};
cout << delivery(3, 2, 8, p);
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

boxes.cpp:7:9: error: ambiguating new declaration of 'int64_t delivery(int, int, int, int*)'
    7 | int64_t delivery(int N, int K, int L, int p[]) {
      |         ^~~~~~~~
In file included from boxes.cpp:1:
boxes.h:4:11: note: old declaration 'long long int delivery(int, int, int, int*)'
    4 | long long delivery(int N, int K, int L, int p[]);
      |           ^~~~~~~~