This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//by szh
#include<bits/stdc++.h>
#include "boxes.h"
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
const int maxn = 1e7+10;
ll pre[maxn],suf[maxn];
long long delivery(int N, int K, int L, int p[]) {
memset(pre,0,sizeof(pre));
memset(suf,0,sizeof(suf));
rep(i,0,N) {
pre[i] = pre[i-i%K] + min(p[i]*2,L);
if (i%K==0 and i!=0) pre[i] += pre[i-K];
}
for(int i=N-1;i>=0;i--) {
suf[i] = suf[i+(N-1-i)%K] + min((L-p[i])*2,L);
if ((N-1-i)%K==0 and i!=N-1) suf[i] += suf[i+K];
}
ll ans = min(suf[0],pre[N-1]);
rep(i,0,N-1) ans = min (ans,pre[i]+suf[i+1]);
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... |