제출 #798429

#제출 시각아이디문제언어결과실행 시간메모리
798429qthang2k11선물상자 (IOI15_boxes)C++17
10 / 100
1 ms340 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e7 + 5; ll pref[N], suff[N]; int *p; ll delivery(int n, int k, int m, int _p[]) { // n <= m, duoc dua toi da k if (m == 1) return 0; // if (n == 1) return min({m - 1, p[0] * 2, }); p = _p; for (int i = 0; i < n; i++) { pref[i] = (i - k >= 0 ? pref[i - k] : 0) + 2LL * p[i]; } for (int i = n - 1; i >= 0; i--) { suff[i] = (i + k < n ? suff[i + k] : 0) + 2LL * (m - p[i]); } ll ans = 1LL * m * n; for (int i = 0; i < n; i++) { ans = min(ans, pref[i] + suff[i + 1]); ll cur = 0; if (i - 1 >= 0) cur += pref[i - 1]; if (i + k < n) cur += suff[i + k]; cur += m; ans = min(ans, cur); } 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...