# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
276009 | stoyan_malinin | Boxes with souvenirs (IOI15_boxes) | C++14 | 1 ms | 384 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 "grader.cpp"
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, k, l;
long long evalVector(vector <int> v, int sz)
{
long long answer = 0;
for(int i = sz;i>=0;i-=k) answer += 2*min(v[i], l-v[i]);//, cout << v[i] << '\n'
return answer;
}
long long solve(vector <int> v1, vector <int> v2)
{
long long answer = 0;
answer = evalVector(v1, v1.size()-1) + evalVector(v2, v2.size()-1);
return answer;
}
vector <int> invertVector(vector <int> v)
{
vector <int> out;
for(int x: v) out.push_back(l-x);
return out;
}
long long delivery(int N, int K, int L, int p[])
{
n = N;
k = K;
l = L;
vector <int> v1, v2;
for(int i = 0;i<n;i++)
{
if(p[i]==0) continue;
if(p[i]<L-p[i]) v1.push_back(p[i]);
else v2.push_back(p[i]);
}
sort(v1.begin(), v1.end());
sort(v2.begin(), v2.end(), greater <int>());
return min(solve(v1, v2), solve(invertVector(v2), invertVector(v1)));
//return solve(invertVector(v2), invertVector(v1));
}
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... |