Submission #420298

#TimeUsernameProblemLanguageResultExecution timeMemory
420298AzimjonBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms296 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const int INF = 2e9; long long delivery(int n, int k, int L, int p[]) { long long ans = 0; double ur = L / 2; int l, r; l = 0; r = n - 1; while (l + k - 1 < n && p[l + k - 1] <= ur) { ans += 2 * p[l + k - 1]; l += k; } // cerr << ans << endl; while (r - k + 1 >= 0 && p[r - k + 1] > (ur)) { ans += 2 * (L - p[r - k + 1]); r -= k; } int i; for (i = l; i <= r; i++) { if (p[i] > ur) break; } long long qo = 0; if (l <= i - 1) qo += 2 * p[i - 1]; if (i <= r) qo += 2 * (L - p[i]); int qs = (r - l + 1); if (qs <= 0) return ans; if (qs > k) { int t = qs - i; long long al = min(2 * p[l + t - 1] + L, 2 * p[r - t + 1] + L); qo = min(al, qo); } else { qo = min(qo, (long long)L); } cerr << ans << endl; return ans + qo; }
#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...