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 fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<ll, ll>
#define ld long double
#define nl endl
#define tb '\t'
#define sp ' '
#define sqr(x) (x)*(x)
#define arr3 array<ll, 3>
using namespace std;
const ll MX=200005, MOD=1000000007, BLOCK=160, INF=1e9+7, LG=62;
const ll INFF=1000000000000000004;
const ld ERR=1e-6, pi=3.14159265358979323846;
long long delivery(int N, int K, int L, int p[]) {
ll pref[N], suff[N], ans;
for(int i=0; i<N; i++){
pref[i]=2*p[i];
if(i>=K){
pref[i]=min(pref[i], (ll)L);
pref[i]+=pref[i-K];
}
}
ans=pref[N-1];
for(int i=N-1; i>=0; i--){
suff[i]=2*(L-p[i]);
if(i+K<N){
suff[i]=min(suff[i], (ll)L);
suff[i]+=suff[i+K];
}
ans=min(ans, suff[i]+(i ? pref[i-1] : 0));
}
return ans;
}
// int main() {
// int N, K, L, i;
// cin >> N >> K >> L;
// int *p = (int*)malloc(sizeof(int) * (unsigned int)N);
// for (i = 0; i < N; i++) {
// cin >> p[i];
// }
// cout << delivery(N, K, L, p) << nl;
// return 0;
// }
# | 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... |