Submission #793550

#TimeUsernameProblemLanguageResultExecution timeMemory
793550UltraFalconBoxes with souvenirs (IOI15_boxes)C++17
10 / 100
1 ms212 KiB
// pragmas #ifndef DEBUG #endif #include <bits/stdc++.h> #include "boxes.h" // #define int long long using ll = long long; using namespace std; long long delivery(int N, int K, int L, int p[]) { vector<ll> cost_pref(N, 0); for (int i=0; i<N; i++) { if (i>=K) cost_pref[i] = cost_pref[i-K]; cost_pref[i] += 2*p[i]; } vector<ll> cost_suff(N, 0); for (int i=N-1; i>=0; i--) { if (i+K < N) cost_suff[i] = cost_suff[i+K]; cost_suff[i] += 2*(L-p[i]); } // for (auto &x : cost_pref) { // cerr << x << " "; // } ll res = min(cost_pref[N-1], cost_suff[0]); for (int i=0; i<N; i++) { res = min(res, cost_pref[i]+(ll)L+cost_suff[min(N-1, i+K)]); res = min(res, cost_pref[i]+cost_suff[min(N-1, i+1)]); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...