Submission #413788

#TimeUsernameProblemLanguageResultExecution timeMemory
413788ak2006Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h" using namespace std; #include <bits/stdc++.h> #define ll long long #define vl vector<ll> long long delivery(int N, int K, int L, int pos[]) { vl pref(n),suf(n); for (int i = 0;i<n;i++)pref[i] = 1ll * 2 * 1ll * pos[i] + (i >= k ? pref[i - k] : 0); for (int i = n - 1;i>=0;i--)suf[i] = 1ll * 2 * 1ll * (1ll * L - 1ll * pos[i]) + (i + k < n ? suf[i + k] : 0); ll ans = min(pref[n - 1],suf[0]); for (int i = 0;i<n - 1;i++)ans = min(ans,pref[i] + suf[i + 1]); for (int i = 0;i<n;i++) ans = min(ans,(i >= 1 ? pref[i - 1] : 0) + (i + k < n ? suf[i + k] : 0) + L); return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:7:13: error: 'n' was not declared in this scope
    7 |     vl pref(n),suf(n);
      |             ^
boxes.cpp:8:69: error: 'k' was not declared in this scope
    8 |     for (int i = 0;i<n;i++)pref[i] = 1ll * 2 * 1ll * pos[i] + (i >= k ? pref[i - k] : 0);
      |                                                                     ^
boxes.cpp:9:90: error: 'k' was not declared in this scope
    9 |     for (int i = n - 1;i>=0;i--)suf[i] = 1ll * 2 * 1ll * (1ll * L - 1ll * pos[i]) + (i + k < n ? suf[i + k] : 0);
      |                                                                                          ^
boxes.cpp:13:57: error: 'k' was not declared in this scope
   13 |         ans = min(ans,(i >= 1 ? pref[i - 1] : 0) + (i + k < n ? suf[i + k] : 0) + L);
      |                                                         ^
boxes.cpp:6:24: warning: unused parameter 'N' [-Wunused-parameter]
    6 | long long delivery(int N, int K, int L, int pos[]) {
      |                    ~~~~^
boxes.cpp:6:31: warning: unused parameter 'K' [-Wunused-parameter]
    6 | long long delivery(int N, int K, int L, int pos[]) {
      |                           ~~~~^