제출 #287135

#제출 시각아이디문제언어결과실행 시간메모리
287135Kastanda선물상자 (IOI15_boxes)C++11
100 / 100
565 ms236664 KiB
// M #include<bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; const int N = 10000007; int n, k, L, A[N]; ll P[N], S[N]; long long delivery(int _n, int _k, int _L, int _p[]) { k = _k; L = _L; for (int i = 0; i < _n; i ++) if (_p[i]) A[++ n] = _p[i]; ll Mn = (n + k - 1) / k * (ll)L; for (int i = 1; i <= n; i ++) { if (i >= k) P[i] = P[i - k]; P[i] += A[i]; } for (int i = n; i; i --) { if (i + k <= n) S[i] = S[i + k]; S[i] += L - A[i]; } for (int i = 0; i <= n; i ++) { Mn = min(Mn, (P[i] + S[i + 1]) * 2LL); ll s = 0; if (i + k + 1 <= n) s = S[i + k + 1]; Mn = min(Mn, (P[i] + s) * 2LL + L); } return Mn; }
#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...