# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172095 | gs18103 | Boxes with souvenirs (IOI15_boxes) | C++14 | 2 ms | 376 KiB |
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 fi first
#define se second
#define eb emplace_back
#define em emplace
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int MAX = 101010;
const int INF = 1e9;
const ll LINF = 1e18;
long long delivery(int N, int K, int L, int p[]) {
vector <ll> l, r, suml, sumr;
for(int i = 0; i < N; i++) {
if(p[i] == 0) continue;
if(p[i] <= L / 2) l.eb(p[i]);
else r.eb(L-p[i]);
}
suml.eb(0), sumr.eb(0);
for(int i = 1; i <= l.size(); i++) {
if(i < K) suml.eb(l[i-1]);
else suml.eb(suml[i-K] + l[i-1]);
}
for(int i = 1; i <= r.size(); i++) {
if(i < K) sumr.eb(r[i-1]);
else sumr.eb(sumr[i-K] + r[i-1]);
}
ll ans = (suml.back() + sumr.back()) * 2;
for(int i = max(0, K - (int)r.size()); i <= min(K, (int)l.size()); i++) {
ans = min(ans, (suml[l.size()-1-i] + sumr[r.size()-1-K+i]) * 2 + L);
}
return ans;
}
Compilation message (stderr)
# | 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... |