제출 #314156

#제출 시각아이디문제언어결과실행 시간메모리
314156joseacaz선물상자 (IOI15_boxes)C++17
0 / 100
1 ms384 KiB
#include "boxes.h" #include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; typedef vector<int> vi; const int MAXN = 1e7 + 5; int N, K, L; ll pre[MAXN], suf[MAXN]; ll delivery(int _n, int _k, int _l, int p[]) { N = _n, K = _k, L = _l; for(int i = 0; i < N; i++) pre[i] = (i - K >= 0 ? pre[i - K] : 0) + 2*p[i]; for(int i = N - 1; i >= 0; i--) suf[i] = (i + K < N ? suf[i + K] : 0) + 2*(L-p[i]); ll ans = min(min(pre[N - 1], suf[0]), min(L + suf[K], pre[N - K - 1] + K)); for(int i = 0; i < N - 1; i++) ans = min(ans, pre[i] + suf[i + 1]); for(int i = 0; i < N - K - 1; i++) ans = min(ans, pre[i] + suf[i + K + 1] + L); 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...