제출 #569731

#제출 시각아이디문제언어결과실행 시간메모리
569731saarang123선물상자 (IOI15_boxes)C++17
100 / 100
609 ms275168 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; long long delivery(int N, int K, int L, int p[]) { ll pref[N], suf[N]; for(int i = 0; i < N; ++i){ pref[i] = p[i] * 2 + (i >= K ? pref[i - K] : 0); } for(int i = N - 1; i >= 0; --i){ suf[i] = (L - p[i]) * 2 + (i + K < N ? suf[i + K] : 0LL); } ll ans = min(pref[N - 1], suf[0]); for(int i = 0; i + 1 <N; ++i) ans = min(ans, pref[i] + suf[i + 1]); for(int i = 0; i < N; ++i){ ll curr = L; if(i) curr += pref[i - 1]; if(i + K < N) curr += suf[i + K]; ans = min(ans, curr); } 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...