Submission #1264678

#TimeUsernameProblemLanguageResultExecution timeMemory
1264678InvMODBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define eb emplace_back #define vi vector<int> #define pi pair<int,int> #define sz(v) (int)(v).size() #define all(v) (v).begin(), (v).end() #define compact(v) (v).erase(unique(all(v)), (v).end()) template<class T> using upq = priority_queue<T, vector<T>, greater<T>>; template<class T> int lwrbound(const vector<T>& a, const T& b, const int s = 0){return int(lower_bound(s + all(a), b) - a.begin());} template<class T> int uprbound(const vector<T>& a, const T& b, const int s = 0){return int(upper_bound(s + all(a), b) - a.begin());} #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define ROF(i, a, b) for(int i = (a); i >= (b); i--) #define sumof(x) accumulate(all(x), 0ll) #define dbg(x) "[" << #x " = " << (x) << "]" #define el "\n" //#define name "InvMOD" using ll = long long; using ld = long double; template<class T> bool ckmx(T& a, const T b){return (a < b ? a = b, true : false);} template<class T> bool ckmn(T& a, const T b){return (a > b ? a = b, true : false);} ll delivery(int n, int k, int l, vi a){ vector<ll> pos(n + 1); FOR(i, 1, n){ pos[i] = a[i - 1]; } vector<ll> pre(n + 1), suf(n + 2); FOR(i, 1, n){ pre[i] = pre[max(0, i - k)] + pos[i] * 2; } ROF(i, n, 1){ suf[i] = suf[min(n + 1, i + k)] + (L - pos[i]) * 2; } ll ans = 1e18; FOR(i, 0, n){ ckmn(ans, pre[i] + suf[i + 1]); } return ans; } #ifdef name int32_t main() { freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); int n, k, L; cin >> n >> k >> L; vi pos(n); FOR(i, 0, n - 1) cin >> pos[i]; cout << delivery(n, k, L, pos) << el; return 0; } #endif // name

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, std::vector<int>)':
boxes.cpp:48:44: error: 'L' was not declared in this scope
   48 |         suf[i] = suf[min(n + 1, i + k)] + (L - pos[i]) * 2;
      |                                            ^