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 ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 2e5+5;
const ll INF = 1e15+7;
long long delivery(int N, int K, int L, int p[]){
ll x,i,left[N+1],right[N+1];
ll sum[K],ans=INF,cur;for(i=0;i<K;i++)sum[i]=0;
//sum[i]=soma do effor para todos os alunos =i(mod k)
for(i=0;i<N;i++){//horario ate este dude
cur = p[i] + min(p[i], L-p[i]);
x=i%K;
sum[x]+=cur;
left[i]=sum[x];
// cout<<i<<" "<<left[i]<<endl;
}
for(i=0;i<K;i++)sum[i]=0;
right[N]=0;
for(i=N-1;i>=0;i--){//horario ate este dude
cur = L-p[i] + min(p[i], L-p[i]);
x=i%K;
sum[x]+=cur;
right[i]=sum[x];
}
for(i=0;i<N;i++){//horario ate este dude
cur = left[i]+right[i+1];
ans=min(ans,cur);
// cout<<i<<" "<<cur<<endl;
}
ans=min(ans,right[0]);
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... |