# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937621 | danikoynov | Boxes with souvenirs (IOI15_boxes) | C++14 | 2 ms | 2396 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>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
const int maxn = 1e7 + 10;
int n, k;
ll p[maxn], temp[maxn];
ll L;
ll get_price_left(int x)
{
ll res = 0;
int t = 0;
for (int i = 0; i < x; i ++)
{
//t ++;
//if (t == x || t % k == 0)
res = res + 2 * p[i];
}
return res;
}
ll get_price_right(int x)
{
ll res = 0;
int t = 0;
for (int i = n - 1; i >= n - x; i --)
{
//t ++;
//if (t == x || t % k == 0)
res = res + 2 * (L - p[i]);
}
return res;
}
long long delivery(int N, int K, int _L, int P[])
{
for (int i = 0; i < N; i ++)
p[i] = P[i];
sort(p, p + N);
n = N;
k = K;
L = _L;
ll ans = 0;
for (int i = 0; i < N; i ++)
{
ans = ans + 2 * min(p[i], L - p[i]);
}
//cout << get_price_right(1) << endl;
///exit(0);
ll res = inf;
for (int i = 0; i < N; i ++)
{
ll val = get_price_left(i) + get_price_right(N - i);
//cout << i << " " << val << endl;
res = min(res, val);
//if (N - i - k >= 0)
//{
// val = get_price_left(i) + get_price_right(N - i - k) + L;
//res = min(res, val);
//}
}
return res;
}
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... |