Submission #793549

#TimeUsernameProblemLanguageResultExecution timeMemory
793549UltraFalconBoxes with souvenirs (IOI15_boxes)C++17
0 / 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<int> 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<int> 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_suff) { // cerr << x << " "; // } int res = min(cost_pref[N-1], cost_suff[0]); for (int i=0; i<N; i++) { res = min(res, cost_pref[i]+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...