이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "boxes.h"
using namespace std;
#define ll long long
#define all(x) x.begin() , x.end()
#define sz(x) (ll)x.size()
const ll INF = 1e18 + 5;
ll delivery(int N, int K, int L, int p[]){
ll n = N, k = K , l = L;
ll ar[n + 5], pre[n + 5], suf[n + 5];
ar[0] = 0;
vector<ll> v;
for(ll i = 1 ; i <= n ; i++) v.push_back(p[i-1]);
reverse(all(v));
while(!v.empty() && v.back() == 0) v.pop_back();
reverse(all(v));
n = sz(v);
if(n == 0) return 0;
for(ll i = 1 ; i <= n ; i++) ar[i] = v[i - 1];
pre[0] = suf[n + 1] = 0;
for(ll i = 1 ; i <= n ; i++) pre[i] = ar[i] * 2 + pre[max(0LL , i - k)];
for(ll i = n ; i >= 1; i--) suf[i] = 2 * ((l - ar[i]) % l) + suf[min(n + 1 , i + k)];
ll ans = INF;
for(ll i = 0; i <= n ; i++) ans = min(ans, pre[i] + suf[i+1]);
return ans;
}
/*void _(){
ll n,k,l;
cin >> n >> k >> l;
ll ar[n + 5], pre[n + 5], suf[n + 5];
for(ll i = 1 ; i <= n ; i++) cin >> ar[i];
pre[0] = suf[n + 1] = 0;
for(ll i = 1 ; i <= n ; i++) pre[i] = ar[i] * 2 + pre[max(0LL , i - k)];
for(ll i = n ; i >= 1; i--) suf[i] = 2 * (l - ar[i]) + suf[min(n + 1 , i + k)];
ll ans = INF;
for(ll i = 0; i <= n ; i++) ans = min(ans, pre[i] + suf[i+1]);
cout << ans << '\n';
}
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);
ll tc = 1;//cin >> tc;
while(tc--) _();
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |