제출 #692052

#제출 시각아이디문제언어결과실행 시간메모리
692052zeroesandones선물상자 (IOI15_boxes)C++17
10 / 100
1 ms352 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; using ll = long long; using pi = pair<ll, ll>; using vi = vector<ll>; #define pb emplace_back ll delivery(int N, int K, int L, int p[]) { ll pref[N + 1] = {}; ll suff[N + 1] = {}; for(int i = 1; i <= N; ++i) { if((i - 1) % K == 0) { // have to start a new trip pref[i] = 2 * p[i - 1]; } else { // can continue the last trip pref[i] = 2 * (p[i - 1] - p[i - 2]) + pref[i - 1]; } } suff[0] = 0; for(int i = 1; i <= N; ++i) { if((i - 1) % K == 0) { // have to start a new trip suff[i] = 2 * (L - p[N - i]); } else { // can continue the last trip suff[i] = 2 * (p[N - (i - 1)] - p[N - i]) + suff[i - 1]; } } ll ans = LLONG_MAX; for(int i = 0; i <= N; ++i) { ans = min(ans, pref[i] + suff[N - i]); if(N - i - K >= 0) ans = min(ans, pref[i] + suff[N - i - K] + 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...