This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std ;
#define ii pair<int,int>
#define fi first
#define se second
#define vi vector<int>
#define vii vector<ii>
typedef long long ll ;
ll pre[10000010] , suf[10000010] ;
long long delivery(int n, int k, int L , int arr[]) {
ll l = L ;
for(int i=0;i<n;i++){
if(i <= k) pre[i] = 2LL*arr[i] ;
else pre[i] = 2LL*arr[i] + pre[i-k] ;
}
for(int i=n-1; i >= 0 ;i--){
if(n - i - 1 <= k) suf[i] = 2LL*(l - arr[i]) ;
else suf[i] = suf[i+k] + 2LL* (l-arr[i]) ;
}
ll res = l + suf[k] ;
for(int i = k ; i<n ; i++) res = min(res , pre[i-k] + l + suf[k+1]) ;
res = min(res , suf[0]) ;
for(int i=0;i<n;i++) res = min(res , pre[i] + suf[i+1]) ;
return res ;
}
# | 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... |