제출 #947007

#제출 시각아이디문제언어결과실행 시간메모리
947007Nelt선물상자 (IOI15_boxes)C++17
10 / 100
1 ms348 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++) if (L <= min(p[i] * 2, (L - p[i]) * 2)) 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...