# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307691 | kylych03 | 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 <bits/stdc++.h>
#include "boxes.h"
//#include "grader.cpp"
//#define int long long
using namespace std;
long long pra[10000001], prb[10000001];
long long delivery(int n, int k, int l, int p[]) {
long long K = k;
long long L = l;
long long N = n;
vector <long long > a,b;
sort(p, p+N);
for(int i = 0; i < N; i++){
if(p[i] <= L/2)
a.push_back(p[i]);
else
b.push_back(L-p[i]);
}
sort(b.begin(), b.end());
long long res = 0;
for(int i = 0 ; i < a.size();i++)
if(i<K)
pra[i] = a[i]*2;
else
pra[i] = a[i] * 2 + pra[i-K];
for(int i = 0 ; i < b.size();i++)
if(i<K)
prb[i] = b[i]*2;
else
prb[i] = b[i] * 2 + prb[i-K];
if( a.size()==0)
res = prb[b.size() -1 ];
else
if(b.size()==0)
res = pra[a.size() -1 ];
else
res = pra[a.size() - 1] + prb[b.size() -1 ];
long long x = 0;
for(long long i = a.size() - 2, j= 1; j <= K && i>=0 ; j++,i--){
if(b.size() >= K - j)
x = prb[b.size() - (K-j)-1];
else
x = 0;
res = min (res, pra[i] + L + x);
}
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... |