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>
#define fi first
#define se second
#define ll long long
using namespace std;
typedef pair<ll,ll> pii;
const ll MAXN = 1e7+10;
const ll INF = 2e18+10;
int n, k, l;
int a[MAXN];
ll ans = INF;
long long delivery(int N, int K, int L, int p[]) {
n = N; k = K; l = L;
for(int i=0; i<n; i++) a[i+1] = p[i];
//cout << n << ' ' << k << ' ' << a[1] << " p\n";
ll nw = 0;
for(int i=1; i<=n; i++){ // paling terakhirnya ada di i
nw = 0;
for(int j=i; j>=1; j-=k){
if(a[j] <= l/2) nw += 2*a[j];
else nw += l;
}
for(int j=i+1; j<=n; j+=k){
if(a[j] <= l/2) nw += l;
else nw += 2*(l-a[j]);
}
ans = min(ans, nw);
}
return ans;
}
# | 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... |