Submission #946998

#TimeUsernameProblemLanguageResultExecution timeMemory
946998NeltBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
504 ms293892 KiB
#include <bits/stdc++.h> #define ll long long #define endl "\n" using namespace std; ll delivery(int n, int k, int L, int p[]) { ll ans = 1e18; ll pref[n], suf[n]; for (ll i = 0; i < n; i++) pref[i] = (i - k < 0 ? 0 : pref[i - k]) + p[i]; for (ll i = n - 1; i >= 0; i--) suf[i] = (i + k >= n ? 0 : suf[i + k]) + L - p[i]; for (ll i = -1; i < n; i++) ans = min(ans, (i >= 0 ? pref[i] : 0) * 2 + (i + 1 < n ? suf[i + 1] : 0) * 2); for (ll i = 0; i < n; i++) ans = min(ans, (i - 1 >= 0 ? pref[i - 1] : 0) * 2 + L + (i + k < n ? suf[i + k] : 0) * 2); return ans; } // void solve() // { // } // signed main() // { // ios_base::sync_with_stdio(0); // cin.tie(0); // ll t = 1; // // precomp(); // // cin >> t; // for (ll i = 1; i <= t; i++) // solve(); // cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n"; // }
#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...