Submission #1058977

#TimeUsernameProblemLanguageResultExecution timeMemory
1058977andrei_iorgulescuBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long; ll inf = (ll)1e9 * (ll)1e9; ll delivery(int N, int k, int L, int positions[]) { vector<int> p(N + 1); for (int i = 1; i <= N; i++) p[i] = positions[i - 1]; ll ans = inf; vector<int> revp(N + 1); for (int i = 1; i <= N; i++) revp[i] = (L - p[i]); ll s1 = 0, s2 = 0; for (int i = 1; i < N; i++) { if ((N + 1 - i) % k == 0) s2 += min(L, 2 * revp[i]); } for (int m = 0; m <= N; m++) { ///Mk de la 1 la m - 1 if (m - 1 >= 0 and (m - 1) % k == 0) s1 += min(L, 2 * p[m - 1]); ///N + 1 - Mk de la m + 2 la N if ((N - m) % k == 0 and m + 1 <= N) s2 -= min(L, 2 * revp[m + 1]); ll kk = s1 + s2; if (m != 0) kk += min(L, 2 * p[m]); if (m != N) kk += min(L, 2 * revp[m + 1]); ans = min(ans,kk); } return ans; }
#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...