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>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define lb lower_bound
#define ub upper_bound
#define sz(v) int((v).size())
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
long long delivery(int n, int k, int l, int p[]) {
sort(p, p + n);
ll pref[n], suff[n];
for (int i = 0; i < n; i++) {
pref[i] = p[i] * 2;
if (i >= k) {
pref[i] += pref[i - k];
}
}
for (int i = n - 1; i >= 0; i--) {
suff[i] = (l - p[i]) * 2;
if (i + k < n) {
suff[i] += suff[i + k];
}
}
ll ans = 1e18;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
if (i + j > n) break;
ans = min(ans, (n - i - j - 1 + k) / k * l + (i ? pref[i - 1] : 0) + (j ? suff[n - j] : 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... |