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 pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long delivery(int N, int K, int L, int a[]){
vector<ll> pk(K, 0);
vector<ll> pr(N + 1, 0);
rep(i, 0, N){
pk[i % K] += a[i] + min(a[i], L - a[i]);
pr[i] = pk[i % K];
}
vector<ll> su(N + 1, 0);
vector<ll> sk(N + 1, 0);
per(i, N - 1, 0){
sk[i % K] += (L - a[i]) + min(a[i], L - a[i]);
su[i] = sk[i % K];
}
ll best = min(su[0], pr[N - 1]);
rep(i, 1, N){
best = min(best, pr[i - 1] + su[i]);
}
return best;
}
# | 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... |